@foreach($audiolanguages as $lang)
@php
$audiogenreitems = NULL;
$audiogenreitems = array();
foreach ($menu_data as $key => $item)
{
$gmovie = App\Movie::join('videolinks','videolinks.movie_id','=','movies.id')
->select('movies.id as id','movies.title as title','movies.type as type','movies.status as status','movies.genre_id as genre_id', 'movies.a_language as a_language','movies.thumbnail as thumbnail','movies.rating as rating','movies.duration as duration','movies.publish_year as publish_year','movies.maturity_rating as maturity_rating','movies.detail as detail','movies.trailer_url as trailer_url','videolinks.iframeurl as iframeurl','movies.slug as slug','movies.tmdb as tmdb','movies.is_custom_label as is_custom_label','movies.label_id as label_id')
->where('movies.is_upcoming','!=' ,1)
->where('movies.id',$item->movie_id)->first();
if(isset($gmovie->a_language)) {
foreach (explode(',',$gmovie->a_language) as $key => $aid) {
if($aid==$lang->id){
if(isset($gmovie) && $gmovie != NULL){
$audiogenreitems[] = $gmovie;
}
}
}
}
if($section->order == 1){
arsort($audiogenreitems);
}
if(count($audiogenreitems) == $section->item_limit){
break;
exit(1);
}
}
$audiogenreitems = array_values(array_filter($audiogenreitems));
foreach ($menu_data as $key => $item)
{
$gtvs = App\Tvseries::
join('seasons','seasons.tv_series_id','=','tv_series.id')
->join('episodes','episodes.seasons_id','=','seasons.id')
->join('videolinks','videolinks.episode_id','=','episodes.id')
->select('seasons.id as seasonid','tv_series.genre_id as genre_id','tv_series.id as id','tv_series.type as type','seasons.a_language as a_language', 'tv_series.status as status','tv_series.thumbnail as thumbnail','tv_series.title as title','tv_series.rating as rating','seasons.publish_year as publish_year','tv_series.maturity_rating as age_req','tv_series.detail as detail','seasons.season_no as season_no','videolinks.iframeurl as iframeurl','seasons.trailer_url as trailer_url','seasons.tmdb as tmdb','tv_series.is_custom_label as is_custom_label','tv_series.label_id as label_id')
->where('tv_series.id',$item->tv_series_id)->first();
if(isset($gtvs->a_language)) {
foreach (explode(',',$gtvs->a_language) as $key => $atid) {
if($atid==$lang->id){
if(isset($gtvs) && $gtvs != NULL){
$audiogenreitems[] = $gtvs;
}
}
}
}
if($section->order == 1){
arsort($audiogenreitems);
}
if(count($audiogenreitems) == $section->item_limit*2){
break;
exit(1);
}
}
$audiogenreitems = array_values(array_filter($audiogenreitems));
@endphp