1.

How to use soft delete in laravel?

Answer»

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 soft delete 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.



Discussion

No Comment Found