srph/laravel-collection-shallow-to-array

This package is abandoned and no longer maintained. No replacement package was suggested.

Apply a shallow toArray to a Collection

v0.1.0 2016-01-05 20:20 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:54:32 UTC


README

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);