Insert Query in Laravel Eloquent ORM
Create Controller
php artisan make:controller customerController Configure routes:
Go to routes>web.php
index is a function which return customer page and store is a function which store the data submitted through form. as given below code.
App>Http>Controllers:
";
print_r($request->all());
$customers = new Customers;
$customers->name = $request['name'];
$customers->email = $request['email'];
$customers->password = md5($request['password']);
$customers->city = $request['city'];
$customers->state = $request['state'];
$customers->address = $request['address'];
$customers->gender = $request['gender'];
$customers->dob = $request['dob'];
$customers->save();
}
}
Above code use to insert data. $customers->name is a database name and $request['name']; is a name which is present in input tag.
Note - Target table using - use App\Models\Customers; because table name is customers in the database>migration>customers_table.
App>Models>Customers.php
The form is given below
Create a file inside resources>views>customer.blade.php
Customer Registration
Comments
Post a Comment