Reputation: 641
I've made a small Trait for filtering an Eloquent
Query. Now I want to apply this function in the Trait to each SELECT
query before returning instead of calling
$data = MyModel::all()->filterable()
,
$data = MyModel::with('foo')->filterable()
etc each time. Is this actually possible?
For example, the nullable package does it by observing
via static::saving(function ($model) { ...
Can this be done for selecting data, too?
Upvotes: 0
Views: 1120