HOW TO INSERT VALUES IN TABLES USING LARAVEL FRAMEWORK
Step 1:
First create a
database in your SQL server. Here my database name is aalavai_technologies.
Now in the .env
file we have to give all the information that they asked. Like I had given
below.
Step 2: Now we have to create migration and model at the same time to add
tables in our database. For that we have to open our terminal and type the
below command
Command: php artisan make:model “model name” -m
My model name is
Member.
Note: Model name should start in capital and would be singular so that we can
access our table by not mentioning it.
The migration
file will start with small letter and will be plural as our model name
Now you can see
the migration (marked in red) and the model file (marked in green)
After saving it
give php artisan migrate in the
terminal
Step 4: Now in your database you can see a table (members) migrated with these
attributes.
Then you have to create a controller. For that in terminal we have to give command php artisan make:controller “controller name” . Here I had create a controller name as aalavai.
Step 5:
(a).After that we have to create a view file registration form for inserting values. Below code is for my view file.
(c). Now go to the web.php
file(route\web.php) and mention the controller like I done below(marked in
green) and give the below codes.
THANKYOU
Comments