Hello! I can not understand how to make the right request. I want to make sorting by several types of tags. For example, in the request there are three tags: fantasy, action, comedy = $ catid I ββwant to get the following form through the request:
| 1 | ΡΠΈΠ»ΡΠΌ 5 |ΡΠ°Π½ΡΠ°ΡΡΠΈΠΊΠ°,Π±ΠΎΠ΅Π²ΠΈΠΊ,ΠΊΠΎΠΌΠ΅Π΄ΠΈΡ| | 2 | ΡΠΈΠ»ΡΠΌ 4 | ΡΠ°Π½ΡΠ°ΡΡΠΈΠΊΠ°,Π±ΠΎΠ΅Π²ΠΈΠΊ| | 3 | ΡΠΈΠ»ΡΠΌ 8 | ΡΠ°Π½ΡΠ°ΡΡΠΈΠΊΠ°,ΠΊΠΎΠΌΠ΅Π΄ΠΈΡ| | 4 | ΡΠΈΠ»ΡΠΌ 9 | Π±ΠΎΠ΅Π²ΠΈΠΊ,ΠΊΠΎΠΌΠ΅Π΄ΠΈΡ| But with such a request
$query = Film::groupBy('film.id')->with('categories'); $query = $query->join('category_film', 'film.id', '=', 'category_film.film_id') ->orderBy('name', 'asc') ->whereIn('category_film.category_id', $catid); He is looking for where there is a mention of these tags. I get this look:
| 1 | ΡΠΈΠ»ΡΠΌ 1 | ΡΠ°Π½ΡΠ°ΡΡΠΈΠΊΠ°| | 2 | ΡΠΈΠ»ΡΠΌ 2 | ΠΊΠΎΠΌΠ΅Π΄ΠΈΡ| | 3 | ΡΠΈΠ»ΡΠΌ 8 | Π±ΠΎΠ΅Π²ΠΈΠΊ| | 4 | ΡΠΈΠ»ΡΠΌ 7 | ΡΠ°Π½ΡΠ°ΡΡΠΈΠΊΠ°| | 5 | ΡΠΈΠ»ΡΠΌ 10| Π±ΠΎΠ΅Π²ΠΈΠΊ| | 6 | ΡΠΈΠ»ΡΠΌ 9 | ΠΊΠΎΠΌΠ΅Π΄ΠΈΡ|
The tables themselves:
films contains:
| id | name |otherNames| slug| | 1 | ΡΠΈΠ»ΡΠΌ 1| films 1|films_1| | 2 | ΡΠΈΠ»ΡΠΌ 2| films 2|films_2| | 3 | Π€ΠΈΠ»ΡΠΌ 3| films 3|films_3| ... | id | name |otherNames| slug| | 1 | ΡΠΈΠ»ΡΠΌ 1| films 1|films_1| | 2 | ΡΠΈΠ»ΡΠΌ 2| films 2|films_2| | 3 | Π€ΠΈΠ»ΡΠΌ 3| films 3|films_3| ... category contains:
| id| name| slug| | 1 |ΡΠ°Π½ΡΠ°ΡΡΠΈΠΊΠ° | ΡΠ°Π½ΡΠ°ΡΡΠΈΠΊΠ°| | 2 | ΠΊΠΎΠΌΠ΅Π΄ΠΈΡ | ΠΊΠΎΠΌΠ΅Π΄ΠΈΡ| | 3 | Π±ΠΎΠ΅Π²ΠΈΠΊ | Π±ΠΎΠ΅Π²ΠΈΠΊ| ...
category_films linking table.
| films_id| category_id| | 5| 1| | 5| 2| | 5| 3| ...
I will be glad to solve this problem.