119

To get all rows from a table, I have to use Model::all() but (from good reason) this doesn't gives me back the soft deleted rows. Is there a way I can accomplish this with Eloquent?

totymedli
  • 29,531
  • 22
  • 131
  • 165

2 Answers2

263

To also get soft deleted models

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

Only soft deleted models in your results

$onlySoftDeleted = Model::onlyTrashed()->get();
marcanuy
  • 23,118
  • 9
  • 64
  • 113
19

Use this to get all record

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

Use this to get record of particular id

Property::withTrashed()->find($list->property_id);
              or

// 1 is unique id of the table

 Model::withTrashed()->find(1);
Robert
  • 5,278
  • 43
  • 65
  • 115
kush
  • 595
  • 5
  • 7
  • 7
    The first part of this answer was already posted. The second part has nothing to do with the question, it is just common Eloquent usage... – totymedli Oct 16 '18 at 20:50