srph / laravel-collection-shallow-to-array
Apply a shallow toArray to a Collection
Installs: 15
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
pkg:composer/srph/laravel-collection-shallow-to-array
Requires
- php: >=5.5.9
Requires (Dev)
- illuminate/support: 4.2.*
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2022-02-01 12:54:32 UTC
README
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);