This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
hambern
I'm trying to get a list of related names on a morphedByMany-relation...
Course
public $morphToMany = [
'contents' => ['Hambern\Teacher\Models\Content', 'table' => 'hambern_teacher_contentables', 'name' => 'contentable'],
];
Content
public $morphedByMany = [
'courses' => ['Hambern\Teacher\Models\Course', 'table' => 'hambern_teacher_contentables', 'name' => 'contentable'],
];
Contentables
Schema::create('hambern_teacher_contentables', function ($table) {
$table->engine = 'InnoDB';
$table->integer('content_id')->unsigned()->index();
$table->integer('contentable_id')->unsigned()->index();
$table->string('contentable_type')->index();
});
Then, on the List Column definition i have:
columns:
courses:
label: Courses
searchable: true
relation: courses
select: @name
But I get an error...
SQLSTATE[HY000]: General error: 2031 (SQL: select `hambern_teacher_contents`.*, (select group_concat(hambern_teacher_courses.name separator ', ') from `hambern_teacher_courses` inner join `hambern_teacher_contentables` on `hambern_teacher_courses`.`id` = `hambern_teacher_contentables`.`contentable_id` where `hambern_teacher_contentables`.`content_id` = `hambern_teacher_contents`.`id` and `hambern_teacher_contentables`.`contentable_type` = ?) as `courses` from `hambern_teacher_contents` order by `name` desc limit 20 offset 0)
How come? Please help me out here...
Last updated
Diego
I had this problem today and I solved it using valueFrom
instead of select
:
columns:
categories:
label: 'CategorÃas'
type: text
relation: categories
valueFrom: name
1-4 of 4