public function index()
{
$collection = collect([
'first' => ['id'=>1, 'name'=>'Karl Marx', 'subject' => 'Production', 'department' => 'Financial'],
'second' => ['id'=>2, 'name'=>'Benjamin Franklin', 'subject' => 'Purchasing', 'department' => 'Marketing'],
'third' => ['id'=>3, 'name'=>'Nelson Mandela', 'subject' => 'Accounting', 'department' => 'Financial'],
'fourth' => ['id'=>4, 'name'=>'Thomas Jefferson', 'subject' => 'Purchasing', 'department' => 'Marketing'],
]);
$grouped = $collection->groupBy('department', true);
dd($grouped);
}