How to get soft deleted records in Laravel 5?

By Hardik Savani | June 24, 2016 | | 53060 Viewer | Category : Laravel


Laravel 5 Eloquent provide soft deleted feature is awesome that way laravel excluded all soft delete record. So By default Laravel Eloquent excludes all the soft deleted records from query results.

But you can get also soft deleted record using withTrashed() of Laravel Eloquent. It will return all record from table.

Item::withTrashed()->get();

You can get only soft deleted row using onlyTrashed() of Laravel Eloquent.

Item::onlyTrashed()->get();



Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.