What is Soft Deletes in laravel with example ?

Updated 29 June 2023

Hello Everyone, In this Article We will learn about Soft Deletes feature of Laravel.

Soft Deleting in Laravel permits you to mark a database record as “deleted” instead of actually deleting it from the database. When records are soft deleted, they are not actually removed from your database. A “deleted_at” attribute is set on the record indicating the date and time at which the record was “deleted”. So that if we incorrectly deleted the specific record we can easily restore them. That’s why Soft Deletes feature is essential and need to exist in our Laravel application.

To enable Soft Deletes for your Laravel application follow the steps written below:

# Create Migration with softDeletes()

In this step we will add “deleted_at” column to our table. We can create this column with softDeletes() helper method.

# Create Model with softDeletes()

In this step we have to add Illuminate\Database\Eloquent\SoftDeletes trait to the model.

# Laravel Soft Deletes and Restore Queries

In this step we will learn about Queries of Soft deletes and Restore Deleted Records.

Delete Query:

Restore Query:

Get Deleted Records:


I hope you will like the Tutorial and it will help you to learn about Laravel Soft Deletes. Please comment below if you have any questions.

You can also hire laravel developers to build your custom solutions on laravel. For exploring the available extensions for Bagisto, you can check out the bagisto extension marketplace.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*

Be the first to comment.

Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home