EntryModel::with($relations) toArray does not include $relations
Created 4 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  —  4 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  —  4 years ago

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

ryanthompson  —  4 years ago

Ok fixed - and pushed.

radic  —  4 years ago

That was quick! Thanks a lot man.

ryanthompson  —  4 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.