In order to populate a dropdown menu with all the records from the Category Model, you can do the following, in your blade (view) file:
{{ Form::select('drpCatg', \App\Category::lists('category_name', 'id')) }}
If you want to add empty or ‘— Select Category —‘ option first, you can do the following, in your blade (view) file:
If you are trying to following code and getting error “Unsupported operand type”
{{ Form::select('drpCatg', ['0' => 'Select'] + \App\Category::lists('category_name', 'id')) }}
Replace above code with
{{ Form::select('drpCatg', ['0' => 'Select'] + \App\Category::lists('category_name', 'id')->all() }}
Article Tags:
Dropdopdown in laravel · Easy dropdowns with Eloquent's Lists method · empty option in Form::select with lists()Article Categories:
Laravel