+2 votes
in Laravel by
How to implement soft delete in Laravel?

1 Answer

0 votes
by

Soft Delete means when any data row is deleted by any means in the database, we are not deleting the data but adding a timestamp of deletion.

We can add soft delete features by adding a trait in the model file like below.

use Illuminate\Database\Eloquent\Model;

use Illuminate\Database\Eloquent\SoftDeletes;

class Post extends Model {

    use SoftDeletes;

    protected $table = 'posts';

    // ...

}

Related questions

0 votes
asked Oct 25, 2023 in Laravel by rajeshsharma
+1 vote
asked Jul 12, 2021 in Laravel by sharadyadav1986
...