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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
To also get soft deleted models
$trashedAndNotTrashed = Model::withTrashed()->get();
Only soft deleted models in your results
$onlySoftDeleted = Model::onlyTrashed()->get();
回答2:
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);