Laravel Collection Custom Grouping with Closure

1 month ago

ihsanberahim

Code

$user = User::find(234);
// $card = $user->cards()->first();

// dispatch(
//   new \App\Jobs\PushNewCardToNetwork($user, $card)
// )->delay(3);

dispatch(
  	new \App\Jobs\SendUserContactsViaEmail($user, 'ihsanberahim@gmail.com')
  )->delay(3);

Output

=> Illuminate\Support\Collection {#1262
     all: [
       0 => Illuminate\Support\Collection {#1264
         all: [
           [
             "id" => 1,
             "ownerId" => 1,
             "type" => "one",
           ],
         ],
       },
       "ownerId" => Illuminate\Support\Collection {#1263
         all: [
           [
             "id" => 2,
             "ownerId" => 1,
             "type" => "two",
           ],
           [
             "id" => 3,
             "ownerId" => 1,
             "type" => "two",
           ],
         ],
       },
     ],
   }
New course: Desktop apps with Electron