static function GetTour($travel_agent_slug, $year, $slug) { Static::init(); $query['slug'] = $slug; $query['with_travel_agent'] = 1; $query['with_related_tours'] = 1; $query['with_count'] = 1; // $query['upcoming'] = true; $tours = Cache::remember('toursss_' . $slug, 20, function () use($query) { return json_decode(self::$api->get(self::$api_url . '/tours?' . http_build_query(array_merge($query, ['access_token' => Session::get('access_token')])))->getBody(), false); }); $tour = $tours->data->data[0]; if (!$tour) { return null; } else { ////////////////////////////////////////////// // Check is published and year is the same // ////////////////////////////////////////////// $published_at = \Carbon\Carbon::parse($tour->published_at); if ($published_at->year != $year) { return null; } ////////////////////////////////////////////// // Check if travel agent is right // ////////////////////////////////////////////// if ($tour->travel_agent->slug != $travel_agent_slug) { return null; } ////////////////////////////////////////////// // add cheapest upcoming schedules // ////////////////////////////////////////////// $tour->cheapest_upcoming_schedules = Static::get_cheapest_upcoming_schedules_to_tour($tour); $tour->upcoming_schedules = Static::get_upcoming_schedules_to_tour($tour->cheapest_upcoming_schedules); } return $tour; }