April 2015
Beginner
144 pages
3h 13m
English
There are two ways of deleting records. If you have a model instance that you have fetched from the database, then you can call the delete method on it:
$cat = Cat::find(1); $cat->delete();
Alternatively, you can call the destroy method, specifying the IDs of the records you want to delete, without having to fetch those records first:
Cat::destroy(1); Cat::destroy(1, 2, 3, 4, 5);
By default, Eloquent will
hard-delete records from your database. This means, once it's deleted, it's gone forever. If you need to retain deleted data (that is, for auditing), then you can use soft deletes. When deleting a model, the record is kept in the database but instead a deleted_at timestamp is set, and any records with this timestamp set ...
Read now
Unlock full access