Looking to hire Laravel developers? Try LaraJobs
This package is not available.

laravel-collection-shallow-to-array maintained by srph

Description
Apply a shallow toArray to a Collection
Author
Last update
2016/01/14 19:30 (dev-master)
License
Links
Downloads
15

Comments
comments powered by Disqus

laravel-collection-shallow-to-array

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

Apply a shallow toArray to a Collection.

Deprecation Notice

Use Collection#all instead. This utility doesn't make any sense; created out of author's laziness to read the API Documentation.

Huh?

Calling toArray of a Collection with Eloquent models (e.g., User::all()) also applies toArray to each item in the collection. Here's a comparison with Collection toArray:

- User::all()->toArray(); // [[], [] []];
+ collection_shallow_to_array(User::all()); // [User, User, User]

Installing

composer require srph/laravel-collection-shallow-to-array

Usage

$users = Users::all();
$array = collection_shallow_to_array($users);