Example #1
0
 public static function aggregate_films($title)
 {
     $films = DB::table('catalog')->leftJoin('omdb', 'catalog.title', '=', 'omdb.title_id')->select('catalog.title', 'catalog.venue', 'catalog.cinema', 'catalog.time', 'catalog.day', 'catalog.month', 'catalog.year', 'omdb.img', 'omdb.title_id', 'omdb.runtime', 'omdb.genre', 'omdb.imdb_rating', 'omdb.plot', 'omdb.website', 'omdb.tomato_url')->where('catalog.title', '=', $title)->get();
     $replace = Selector::replace('_', " ", $films[0]->title);
     $trailer = DB::table('trailers')->select('trailers.trailer')->where('trailers.title', '=', $title)->get();
     $z = 0;
     $tempArray = [];
     $aggregateArray[0]['title_id'] = $films[0]->title;
     $aggregateArray[0]['title'] = $replace;
     $aggregateArray[0]['marker'] = 'search';
     $aggregateArray[0]['trailer'] = $trailer[0]->trailer;
     $aggregateArray[0]['img'] = $films[0]->img;
     $aggregateArray[0]['plot'] = $films[0]->plot;
     $aggregateArray[0]['website'] = $films[0]->website;
     $aggregateArray[0]['tomato_url'] = $films[0]->tomato_url;
     $aggregateArray[0]['genre'] = $films[0]->genre;
     $aggregateArray[0]['runtime'] = $films[0]->runtime;
     $aggregateArray[0]['imdb_rating'] = $films[0]->imdb_rating;
     $aggregateArray[0]['runtime'] = $films[0]->runtime;
     for ($i = 0; $i < count($films); $i++) {
         if (array_search($films[$i]->venue, $tempArray) === false) {
             $tempArray[$z] = $films[$i]->venue;
             $aggregateArray[$z]['venue'] = $films[$i]->venue;
             $aggregateArray[$z]['cinema'] = $films[$i]->cinema;
             $z++;
         }
     }
     return $aggregateArray;
 }