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
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

hambern
hambern

Did i find a bug?! :D

tomaszskorupka9424331
tomaszskorupka9424331

Same goes here, after 1year hasn't been fixed?

Diego
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

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.