Querying Soft Deletes in Laravel

By default, Eloquent excludes all the soft deleted records from query results. But, you can force it to get these records.

To get soft deletes with all other records use following code,

$trashedAndNotTrashed = Motorcycle::withTrashed()->get();

To get only soft deletes use the code given below,

$onlyTrashed = Motorcycle::onlyTrashed()->get();

Related Post : Soft Deleting in Laravel


Leave a Comment.