laravel collection to array with key code example
Example 1: laravel eloquent to array key value
Icon::all()->keyBy('name')
Example 2: laravel eloquent to array key value
$roles = collect(DB::table('roles')->get())->keyBy('name');
Icon::all()->keyBy('name')
$roles = collect(DB::table('roles')->get())->keyBy('name');