Top "Laravel-collection" questions

A fluent, convenient wrapper for working with arrays of data provided by Illuminate\Support\Collection class.

Reference next item in a Laravel collection

I am looping through a Laravel collection sorted by created_at to make a timeline. The start date for each …

php laravel laravel-collection
Laravel grouped collection returns object instead of array

I have the following query $outings = Outing::all()->groupBy(function ($item) { return Carbon::parse($item['start'])->…

laravel laravel-collection
Laravel collection sortBy not taking effect

I'm trying to combine and sort the results from several db queries. $events = collect(); $downedEvents = EventDowned::where('mission', $missionId) -&…

php laravel laravel-5 eloquent laravel-collection
Laravel collection converts array to object

If I run $collection->filter(myFilter), Laravel does this annoying thing of adding keys to each model in the …

php json laravel laravel-collection
Transform laravel collection

I need a certain array format like this: $data = [ 1 => ['order' => 3], 2 => ['order' => 2], 3 => ['order' => 1] ]; So when …

php laravel laravel-collection
Laravel using Sum and Groupby

I would like to fetch sum of quantity in each month, so that I can display on bar chart quantities …

php laravel eloquent laravel-5.6 laravel-collection
How to pluck multiple columns in Laravel

I want to get a student's full name, but in my database, I have two different columns: first_name and …

php laravel eloquent laravel-collection