These are the steps on how to Soft Deletes records in your Laravel app. You can refer also the official docs at Soft Deleting.
In case you didn’t understand what soft deleting is, it is a process of deleting a record that is being displayed in your application, without deleting the actual record in the database. In other words, you just prevent your app from displaying all the soft deleted records but keeping it in your actual database.
Some find this method useful, especially if you don’t want user to actually delete a record, or to keep tracking of what records are being deleted, and who deleted those records.
Laravel 5 provides a very simple way on how to soft delete a record. Follow the steps along.
Some Notes before proceeding:
- In case you don’t use migration, just add a datetime() field named ‘deleted_at‘. And it should be nullable.
- If you use data migration just add $table->softDeletes(); just below the $table->timestamps();