I have a method Assets.
It has this this relation:
public function fields() {
return $this->hasManyThrough( CustomField::class, CustomEntity::class,
'id', 'entity_id', 'entity_id' );
}
If I do $asset->fields, the problem is that $asset->fields->id, the id is coming from CustomEntity rather than from CustomField. This is due to the query that is created:
select `custom_fields`.*, `custom_entities`.`id`
from `custom_fields`
inner join `custom_entities`
on `custom_entities`.`id` = `custom_fields`.`entity_id`
where `custom_entities`.`id` = 14
The query would work without the custom_entites
.id
:
select `custom_fields`.*
from `custom_fields`
inner join `custom_entities`
on `custom_entities`.`id` = `custom_fields`.`entity_id`
where `custom_entities`.`id` = 14
Am I doing something wrong or is this a bug?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community