laravel-nestedset
laravel-nestedset copied to clipboard
children relationship is not loaded from model to array
I have database request with data serialized to array
$columns = ['id', '_lft', '_rgt', 'parent_id', 'title', 'slug', 'icon', 'description', 'image', 'metatitle', 'metakey', 'metadesc'];
$result = $this
->startConditions()
->whereSlug($slug)
->select($columns)
->first()
->toArray();
And in output array I see only ancestors relationship. I don't see children. If I debug like that I see only ancestors in array.
$result = $this
->startConditions()
->whereSlug($slug)
->select($columns)
->first();
dd($result, $result->toArray());
but if I try to debug like that then I see children
dd($result, $result->children, $result->toArray());
What is the problem and how I can get children in my array?
At the moment I solved like that, but it seems like a croocked path.
$result = $this
->startConditions()
->whereSlug($slug)
->select($columns)
->first();
$result->children = $result->children->toArray();
$result = $result->toArray();