To manage structured data efficiently by providing the functionality to Create, Read, Update, and Delete records. In this article, We are studying the crud operations in laravel 9 with examples and validating user inputs in laravel.
Create a project on Laravel
Run the below command to create a laravel application.
composer create-project --prefer-dist laravel/laravel:^9.0 laravel-crud
Update the env file
Update the database credentials in the .env file.
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=database-name
DB_USERNAME=user-name
DB_PASSWORD=password
Make a Model and Migration
We are storing information on the database. For that, we make a migration and model using the below command.
php artisan make:model Contact -m
Now, you can check /database/migrations directory. Update the current generated file like below.
public function up()
{
Schema::create('contacts', function(Blueprint $table){
$table->id();
$table->string('name');
$table->string('email');
$table->string('mobile');
$table->timestamps();
})
}
You can read More details on https://bit.ly/3tlEgXi
Top comments (0)