jeudi 27 septembre 2018

How to toggle laravel trashed filter off temporarily?

So I've got an A, which has a B that has a C that has a D. I want to go from A to D, but any one (or all) of the objects might have been deleted. So I have to do this:

$d = $a->b()->withTrashed()->first()->c()->withTrashed()->first()->d()->withTrashed()->first()

Which is horrible. I would really rather do this:

turnOffTrashedFilter();
$d = $a->b->c->d;

Does laravel have such an ability?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire