Eager loading issue :(
hexatex opened this issue · comments
I have a parent model called Category, and two category types, Link & Dynamic. Only one of them has the relationship criteriable()
When I try to load like,
$categories->load('criteria');
I get the error, Call to undefined relationship [criteria] on model [App\Models\Category\Category]'
Is eager loading that relationship possible?
Category
class Category extends Model
{
use Filtered, HasChildren;
/**
* @var array
*/
protected $childTypes = [
'dynamic' => Dynamic::class,
'link' => Link::class,
'regular' => Regular::class,
];
/**
* @var array
*/
protected $fillable = [
'type',
'name',
];
Dynamic
class Dynamic extends Category implements CategoryType, Criteriable
{
use HasParent;
/**
* Criteria
* @return MorphOne
*/
public function criteria()
{
return $this->morphOne(Criteria::class, 'criteriable');
}
Link
class Link extends Category implements CategoryType
{
use HasParent;
/*
* No relationships
*/
I have added
protected $with = ['criteria'];
but that did not work either, no error, just didn't load.
:,(
Hey friends! The team at Tighten has taken Parental back over and we're re-opening the issue tracker, but to give us a clean slate, I'm going to close all old issues that remain from when Caleb closed the issue tracker in 2020. If this is still an outstanding concern with the latest version of Parental, please feel free to open a new issue referencing this one.
Thank you!