Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

There are tons of collection methods that aren't in the documentation but you can find them in the api http://laravel.com/api/4.2/ Maybe groupBy? And of course you can always do it the old fashion way by treating the collection like an array of objects.

Last updated 2 years ago.
0

groupBy would be before retrieval is complete. i was just thinking whether there is a more elegant way of filtering the collection.

so yeah i ended up using the old fashion way of treating the collection like an array of objects.

$allRoles = array();

foreach ($jobRoles as $jobRole) 
{
    $allRoles[$jobRole->slug] = $jobRole;
}
Last updated 2 years ago.
0

there are numerous collection methods for this

API for Support Collection

API for Eloquent Collection

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

parn09 parn09 Joined 21 Jul 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.