Active record, main criteria

Hi all, in my modelSearch I have a filter in the main query for select only record with [‘enabled’=>true], how can I use this filter in all searches without rewriting the condition where in each context every time?


By writing your own filter for your controllers or a behavior for models, which adds a where-clause to each query of the model?
You add this filter to your other model search classes.


Please check this section of the guide.

1 Like

great was what i was looking for, thanks @softark

I have a model with its classic modelSearch only that the filter that I use in modelSearch I wanted to use it also in the main model without writing twice the same condition, here is what I was trying to do. thanks