How to get all rows (soft deleted too) from a tabl

2020-05-22 03:23发布

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?

2条回答
狗以群分
2楼-- · 2020-05-22 04:07

To also get soft deleted models

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

Only soft deleted models in your results

$onlySoftDeleted = Model::onlyTrashed()->get();
查看更多
来,给爷笑一个
3楼-- · 2020-05-22 04:24

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);
查看更多
登录 后发表回答