So, we currently have a polymorphic relationship like so:
| id | entity | entity_id |
| -- | ------ | --------- |
| 1 | box | 12 |
| 2 | shoe | 43 |
The relationship is defined like:
public function Entity()
{
return $this->morphTo('Entity', 'entity', 'entity_id');
}
It seems because of the case-difference, we can pull the column and relation values like:
$this->entity; // 12
$this->Entity; // Box
But, it looks like when we got to eager-load the relationship, it blows up:
Thing::with('Entity'); // Undefined property: App\Thing::$entity
$thing->load('Entity'); // Undefined property: App\Thing::$entity
Anyone know what that undefined property error is telling me? Why does lazy-loading work, but not eager-loading?
(I'm trying to see if we can avoid renaming this for now).