DEV Community

Rohit Urane
Rohit Urane

Posted on

Mastering Efficiency: Unleashing the Power of CRUD Operations in Laravel

Image description

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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();
     })
}
Enter fullscreen mode Exit fullscreen mode

You can read More details on https://bit.ly/3tlEgXi

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay