What is soft delete in laravel?

Soft delete is a laravel feature that helps When models are soft deleted, they are not actually removed from our database. Instead, a deleted_at timestamp is set on the record. To enable soft deletes for a model, we have to specify the softDelete property on the model like this.

In model we have to use namespace
use Illuminate\Database\Eloquent\SoftDeletes;

and we can use this
use SoftDeletes; in our model property.

After that when we will use delete() query then records will not remove from our database. then a deleted_at timestamp is set on the record.

This is the favorite interviewer question in Laravel interview questions.

Suggest An Answer

No suggestions avaliable!

Latest post from Laravel Interview Questions

Ask Question