Hi all, please help me to solve my problem. So let we have blogs. Blogs associated with tags M:M. Accordingly, there is a table which lists all these tags (tags). How to show the blogs with a specific tag it is clear to me, but how in the SearchModel to select all blogs that have absolutely all the available tags?
I tried out 2 options. Others never climb, googling failed.
Option 1:
$tags = ArrayHelper::getColumn(Tag::find()->all(),'id'); // here I get an array with all the existing tags $query->andFilterWhere([ 'service_id' => $tags ]);
Does not work, because it removes all the blogs that have at least some of the tags.
The course 2:
$tags = ArrayHelper::getColumn(Tag::find()->all(),'id'); // here I get an array with all the existing tags foreach ($tags as $one) { $query->andFilterWhere([ 'service_id' => $one ]); }
just not running)
Other options I do not have, please take a look.