Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
259 views
in Technique[技术] by (71.8m points)

php - How to get all rows (soft deleted too) from a table in Laravel?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To also get soft deleted models

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

Only soft deleted models in your results

$onlySoftDeleted = Model::onlyTrashed()->get();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...