There is a problem in querying joined tables. Join three many-to-many tables. But each has an id column from the main table news,img_news, subregions. and a news table can have several sub-regions and several images.
This request is certainly not correct. But as an example.
$news = DB::table('news')
->OrderBy('rating', 'DESC')
->where('region_id', '=', 1)
->join('img_news', 'news.id', '=', 'img_news.news_id')
->join('subregions', 'news.subregion_id', '=', 'news.id')
->select('news.*', 'img_news.img', 'subregions.name_subregion')
->get();
Rather, the problem is in the query, how to make a query to the main table news by region_id, get an array of IDs for these regions. And after that, get on the ID of the region, get their images and sub-regions. I have no thoughts left at all. Thank you for any idea and help !!!