Laravel 7.x and 6.x - Populate select box from database example

June 25, 2017 | Category : Laravel 5 Laravel

we always require to generate dynamic select box from database table like if you have users table and you require to generate drop down box on all users from database. So in this article i will let you know how to populate drop down list from database.

In this example, i simply created users table and added some dummy data. Then i will populate select box using laravel model. So let's see bellow example:

Add Route

Route::get('myform', 'HomeController@myform');

Add Controller Method

public function myform()


$users = User::pluck('name', 'id');

return view('myForm',compact('users'));


Add View

<!DOCTYPE html>



<title>Laravel 5 - Populate select box from database example</title>



{!! Form::open() !!}

{!! Form::select('user_id', $users, null, ['class' => 'form-control']) !!}

{!! Form::close() !!}



Ok, now you can use in your laravel app and check...Enjoy....