EntryModel::with($relations) toArray does not include $relations
Created 6 years ago by radic
$menu = MenuModel::with('links')->find(1)->toArray();
$menu['links']; // should be an array 

This does not happen with EntryModels. I think it has to do with the $cascades property but haven't digged to deep into it.

How can i ensure that toArray() does include the loaded relationships?

ryanthompson  —  6 years ago

Ah good catch! Seems I remember a discussion if Laravel was gonna do toArrayWithRelations or use loaded 😛

Either way - I've update our base model with the laravel one in that regard (Streams Platform v1.3.153). Composer update!

ryanthompson  —  6 years ago

Bah.. there is recursion issue in here. I've reverted and will need to clean up later :-/

ryanthompson  —  6 years ago

Ok fixed - and pushed.

radic  —  6 years ago

That was quick! Thanks a lot man.

ryanthompson  —  6 years ago

I've had to change this to toArrayWithRelations because it was causing weird issues here and there because of it's nested array and Laravel utilities not handling it correctly.