← Back to Home
Article Detail
CRUD Using Laravel For Beginners
Database

CRUD Using Laravel For Beginners

In this article, we will walk through the basic concept of CRUD operations using Laravel. CRUD stands for Create, Read, Update, and Delete, which are the core actions behind most data-driven applications. Laravel makes these operations easier by providing a clean structure with routes, controllers, models, and migrations.

7 min readMarch 2026 ⭐ 4.5

When building a web application, we almost always need to manage data. Whether it is user information, products, blog posts, or transactions, the system must be able to create new data, read existing data, update records, and delete unnecessary data. These four actions form what we call CRUD operations.

Laravel is one of the most beginner-friendly PHP frameworks for handling CRUD operations. It provides tools like migrations, Eloquent ORM, controllers, and routing that help developers write clean and maintainable code.

Instead of writing complex SQL queries manually, Laravel allows us to interact with the database through models. This makes the code easier to understand and keeps the application structure organized.

1. Create a New Laravel Project

First, we need to create a new Laravel project. Laravel provides a simple command that automatically sets up the project structure for us.

composer create-project laravel/laravel crud-app
cd crud-app

After the installation is complete, you will have a fully structured Laravel project with folders for routes, controllers, models, and database migrations.

2. Create a Model and Migration

Next, we create a model and migration. The model represents the table in the database, while the migration defines the structure of that table.

php artisan make:model Post -m

This command creates two things: a Post model and a migration file. Now we can define the columns that will exist in the posts table.

Schema::create('posts', function (Blueprint $table) {
  $table->id();
  $table->string('title');
  $table->text('content');
  $table->timestamps();
});

After defining the table structure, we run the migration to create the table in the database.

php artisan migrate

3. Create a Controller

Controllers are responsible for handling the request and response logic. Instead of putting everything inside routes, Laravel encourages us to keep logic inside controllers.

php artisan make:controller PostController

Inside the controller, we can create functions for each CRUD operation.

use AppModelsPost;

public function index()
{
  return Post::all();
}

4. Define Routes

Routes connect URLs with controller methods. In Laravel, routes are usually defined inside routes/web.php or routes/api.php.

Route::get('/posts', [PostController::class, 'index']);
Route::post('/posts', [PostController::class, 'store']);
Route::put('/posts/{id}', [PostController::class, 'update']);
Route::delete('/posts/{id}', [PostController::class, 'destroy']);

These routes allow our application to list posts, create new posts, update existing posts, and delete posts.

5. Example CRUD Logic

Below is an example of creating a new post using Laravel Eloquent.

public function store(Request $request)
{
  $post = Post::create([
    'title' => $request->title,
    'content' => $request->content
  ]);

  return response()->json($post);
}

Laravel automatically maps the data to the database table through the model. This keeps the code short and easy to read.

6. Recommended Project Structure

As your Laravel application grows, organizing the project becomes very important. Laravel already provides a good structure by default.

app
├── Http
│   └── Controllers
│       └── PostController.php
│
├── Models
│   └── Post.php
│
database
└── migrations

routes
└── web.php

By following this structure, it becomes easier for other developers to understand your project and collaborate with you.

7. Final Thoughts

CRUD operations are the foundation of many applications. Once you understand how to create, read, update, and delete data in Laravel, you can build dashboards, admin panels, blog systems, and many other real-world applications.

Laravel makes this process much smoother by providing clear structure and powerful tools like migrations and Eloquent ORM.

Key Takeaway

Understanding CRUD operations in Laravel gives you a strong foundation for backend development. Once you master these basics, you can start building more advanced features such as authentication systems, dashboards, and full web applications.