Data objects and collections will only get wrapped when sending them as a response, never when calling
toArray or toJson.Default Wrap Key
Define a default wrap key inside a data object:Global Wrap Key
Set a global wrap key inconfig/data.php:
Wrapping Collections
Collections can be wrapped just like data objects:Paginated Collections
Set the data key in paginated collections:Nested Wrapping
A data object included inside another data object will never be wrapped even if a wrap is set:Data Collections Inside Data Objects
A data collection inside a data object will get wrapped when a wrapping key is set (mimicking Laravel resources):Disabling Wrapping
When a data object is wrapped due to the default wrap method or a global wrap key, you can disable wrapping:Getting a Wrapped Array
By default,toArray and toJson never wrap a data object or collection. Get a wrapped array manually: