How To Store Multiple Select Value In Laravel ?

Admin   Laravel   896  2021-03-15 23:40:04

Hi Dev,

In this article, I will show you multiple select value store into the database in laravel app. I want to store all select value into table in laravel.

I will give you full exaple for store multiple option into table in laravel. You need store multiple select value into table with our laravel app then you can use bellow full exmaple. So Let's see full example step by step.

Here i will give solution and full exmaple for store multiple value.



$hobby = $request->input('hobby');

$input['hobby'] = implode(',', $hobby);

Step 1 : Install Laravel App

In First step we require to get fresh Laravel application using bellow command, So open your terminal OR command prompt and run bellow command:


composer create-project --prefer-dist laravel/laravel blog

Database Configuration

In this step, we require to make database configuration, you have to add following details on your .env file.

1.Database Username

1.Database Password

1.Database Name

In .env file also available host and port details, you can configure all details as in your system, So you can put like as bellow:







Step 2: Create users Table and Model

In this step we have to create migration for users table using Laravel php artisan command, so first fire bellow command:


php artisan make:model User -m

After this command you have to put bellow code in your migration file for create users table.




use Illuminate\Database\Migrations\Migration;

use Illuminate\Database\Schema\Blueprint;

use Illuminate\Support\Facades\Schema;

class CreateUsersTable extends Migration



* Run the migrations.


* @return void


public function up()


Schema::create('users', function (Blueprint $table) {








* Reverse the migrations.


* @return void


public function down()





Now we require to run migration be bellow command:


php artisan migrate

After you have to put bellow code in your model file for create users table.




namespace App;

use Illuminate\Database\Eloquent\Model;

class User extends Model


protected $fillable = [




Step 3 : Create Route

now, we need to add route for users controller in laravel application. so open your "routes/web.php" file and add following route.


Route::get('/users','[email protected]');

Route::post('/users','[email protected]')->name('');

Step 4 : Create Controller

Here this step now we should create new controller as UserController. So run bellow command and create new controller.


php artisan make:controller UserController

After successfully run above command . So, let's copy bellow code and put on UserController.php file.




namespace App\Http\Controllers;

use App\User;

use Illuminate\Http\Request;

class UserController extends Controller



* Show the form for creating a new resource.


* @return \Illuminate\Http\Response


public function create()


return view('create');



* Store a newly created resource in storage.


* @param \Illuminate\Http\Request $request

* @return \Illuminate\Http\Response


public function store(Request $request)


$input = $request->all();

$hobby = $input['hobby'];

$input['hobby'] = implode(',', $hobby);


return redirect()->back();



Step: 5 Create View

In last step. In this step we have to create "create" blade file. So mainly we have to create layout file . So finally you have to create following file and put bellow code:



<!DOCTYPE html>



<title>How To Store Multiple Select Value In Laravel ? -</title>



<h1>How To Store Multiple Select Value In Laravel ? Nicesnippets</h1>

<form method="post" action="{{ route('') }}">



<input type="text" name="name">




<select multiple="multiple" name="hobby[]">










<input type="submit" name="btn-submit" value="Save">




Now we are ready to run our example so run bellow command for quick run:


php artisan serve

Now you can open bellow URL on your browser:



It will help you...