Support the ongoing development of Laravel.io →
Database Eloquent

http://laravel.io/bin/DqxWo

Hello,

I have a collection that I would like to filter it down to what I require

  1. Find slots with the earliest start time,
  2. Find remaining slots with the longest duration
  3. Find remaining slots with the lowest penalty

I have applied filters to a collection, and then getting the values of the max duration and min penalty, and subsequently applying the filters again. Thus I am wondering, is there a better way to optimize this set of code?

Thanks!

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

kensim86 kensim86 Joined 23 Apr 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.

© 2025 Laravel.io - All rights reserved.