It is normal that the query Model::all() returns deleted(Soft deleted) model?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
33 views
The documentation says Soft Deleted models are automatically excluded from any of the samples.
spoiler
As noted above, soft deleted models will automatically be excluded from query results. However, you may force soft deleted models to appear in a result set using the withTrashed method on the query:

$flights = App\\Flight::withTrashed()
->where('account_id', 1)
->get();
https://laravel.com/docs/5.6/eloquent#deleting-models
by | 33 views

2 Answers

0 like 0 dislike
By asking lots of questions was able to see the code that the author wrote. From the code it became clear that he overrode the method in the model boot, but forgot to call the parent method boot.

In General, to override the boot model for events is a bad practice. Read the documentation for the recognition of good practice.
by
0 like 0 dislike
So something is badly wrong doing.

Code from the documentation does not say anything about your code.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
110,608 questions
257,187 answers
0 comments
40,796 users