Appearance
How to get all rows (soft deleted too) from a table in Laravel?
In Laravel, you can use the withTrashed() method to retrieve all the rows, including the soft deleted ones, from a table. For example:
Example of using the withTrashed() method to retrieve all the rows from a table in Laravel
php
$rows = ModelName::withTrashed()->get();This will retrieve all the rows, including the soft deleted ones, from the table associated with the ModelName model.
You can also use the onlyTrashed() method to retrieve only the soft deleted rows from a table. For example:
Example of using the onlyTrashed() method to retrieve only the soft deleted rows from a table in Laravel
php
$rows = ModelName::onlyTrashed()->get();This will retrieve only the soft deleted rows from the table associated with the ModelName model.