eloquent get collection change key of array to name of column 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');