Answer the question
In order to leave comments, you need to log in
How to filter all queries by user?
I have a lot of listings in my project, is there any event where I could just slip in the filtering conditions?
something like
if ($entity instanceof OwnerInterface) {
//some Logik
}
->findByUser($user)
, and there is some more logic.
Answer the question
In order to leave comments, you need to log in
Why is it pointless? Not pointless. Controllers can be different: API, Console. Web… there can be different filtering everywhere. So it's definitely not pointless.
As for logic, it's correct. It should not be in the controller! To do this, create your own filtering service. Pass the Query Builder into it and filter as needed and where needed.
You can read more on the EasyAdmin example https://symfony.com/bundles/EasyAdminBundle/curren... or on Laravel example for understanding https://habr.com/en/post/485520/
Laravel example
just for understanding how it can be done.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question