如何从 Laravel 的表中获取所有行(也被软删除)?
要从表中获取所有行,我必须使用 Model::all()
但是(有充分的理由)这不会让我返回软删除的行.有没有办法用 Eloquent 来完成这个任务?
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?
推荐答案
同时获得软删除模型
$trashedAndNotTrashed = Model::withTrashed()->get();
结果中仅软删除模型
$onlySoftDeleted = Model::onlyTrashed()->get();
相关文章