Wednesday, March 8, 2017

Create a new and custom collection

In my app im getting a array of objects, from the table, and in the table i get the information regarding each object, but i need to create a new collection with specific name properties but with the values from the collection i went and get. How can i create a new custom collection from the old one i got from DB?

my code:

$conditions = collect($user->conditions()
            ->withTrashed()
            ->orderBy('updated_at', 'desc')
            ->get());

Im using laravel 5.1.



via Pedro

Advertisement