Currently I have a global scope that filters models by the logged in user’s account_id.
I have used an interface to make sure I implement the boot method on the models I need it on.
This works perfectly fine, but is quite repetitive.
So I’d like to know how to implement this global scope through a trait, just like laravel’s own soft deletes trait.
Any tips or helpers in the right direction would be much appreciated?
Using a Trait to apply a global scope
Currently I have a global scope that filters models by the logged in user’s account_id. I have used an interface to make sure I implement the boot method on the models I need it on. This works perfectly fine, but is quite repetitive.
So I’d like to know how to implement this global scope through a trait, just like laravel’s own soft deletes trait.
Any tips or helpers in the right direction would be much appreciated?
Thanks