تحتوي مجموعات Laravel على العديد من الطرق القوية:
Partition - التقسيم بناءً على شرط
[$admins, $users] = User::all()->partition(fn($user) => $user->isAdmin());Pipe - تحويل المجموعة
$result = collect([1, 2, 3])->pipe(function ($collection) {
return $collection->sum();
});When - المعالجة الشرطية
$collection = collect([1, 2, 3])
->when(true, fn($c) => $c->push(4));تساعدك هذه الطرق على كتابة كود أكثر تعبيرًا وقابلية للصيانة.