Inserting data from <option> to Database in Laravel 5.8

Muqsith Arsyad

I'm trying to insert data into a database with an option menu.

<select class="form-control" name="tim">
    @foreach ($tim as $t)
        <option value="{{ $t->id }}">{{ $t->name }}</option>
    @endforeach
</select>

and this the controller

$data=new Modelverif();
$data->id_profil=$request->id;
$data->$id_pegawai=$request->get('tim');
$data->save();

how to input database with option menu with array?

Vikas Katariya

Blade.php

   <select class="form-control" name="tim">
      @foreach ($tim as $t)
      <option value="{{ $t->id }}">{{ $t->name }}</option>
      @endforeach
    </select>

the controller

$data=new Modelverif();
$data->id_profil=$request->id;
$data->$id_pegawai=$request->tim;  //Or $data->$id_pegawai= $request->input('tim'); 
$data->save();

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Save data into database in Laravel 5

getting error while inserting data to mysql database in laravel 5

Show selected option from database in laravel

Laravel 5 - Typeahead from database

Data fetching from database using vuejs in laravel 8

Problem inserting data in database from option menu using ASP.NET CORE

How to get data from database to view page in laravel 8?

Inserting data to database from textbox using dataset

Inserting data to MySQL database from XML feed

Inserting data into a database from vb6?

Inserting data from a html form into MySQL database

Preventing Empty Data from Inserting into database

Data from input box not inserting in to database

laravel 5 and Ajax get data from database:

POST not inserting data in database

Inserting data from dataGridView to the database error

Unable to show data from database in Laravel after inserting data into database

inserting data into database laravel 5.6 relation belongstomany pivot table

Inserting data from lists into mysql database

errors occurs to inserting data into database (php laravel)

Setting selected option in laravel from database

Laravel update database with value from option

inserting user in database from regitration form laravel 8

Inserting chip in database and show it from database in laravel 8 and materialize css

SOLVED - Laravel multiple foreach for inserting data into database

How to delete data from database in Laravel 8.*

show the data in dropdown fetched from database using laravel 8

Problem in inserting data to database using POST in laravel 8

Inserting data from one database to another conditionally