Ejemplo n.º 1
0
 function getTotalUpcomingSchedulesAttribute()
 {
     if (!isset($this->total_upcoming_schedules)) {
         $destination_ids = new Collection();
         $destination_ids->push($this->id);
         foreach ($this->descendant as $x) {
             $destination_ids->push($x->id);
         }
         $this->total_upcoming_schedules = TourSchedule::whereHas('tour', function ($query) use($destination_ids) {
             $query->InDestinationByIds($destination_ids);
         })->scheduledBetween(\Carbon\Carbon::now(), \Carbon\Carbon::now()->addYear(5))->count();
     }
     return $this->total_upcoming_schedules;
     // $destination_ids = Static::where(function($query) uses ($this) {
     // 	$query->where('id', '=', $this->id)
     // 			->orWhere($this->getPathField(), 'like', $this->attributes[$this->getPathField()] . Static::getDelimiter() . '%')
     // })->join('tours', 'tours.')
     // // calculate this destination total schedules
     // $total_schedule = 0;
     // foreach ($this->tours as $tour)
     // {
     // 	$total_schedule += $tour->schedules->count();
     // }
     // // calculate this destination and its children total schedules
     // $descendants = $this->descendant;
     // $descendants->load('tours', 'tours.schedules');
     // foreach ($descendants as $descendant)
     // {
     // 	foreach ($descendant->tours as $tour)
     // 	{
     // 		$total_schedule += $tour->schedules->count();
     // 	}
     // }
     // return $total_schedule;
 }
Ejemplo n.º 2
0
 public function remove()
 {
     $ids = Session::get('compare_cart');
     if (Input::has('id')) {
         $remove_id = Input::get('id');
         $ids = array_where($ids, function ($k, $v) use($remove_id) {
             return $v != $remove_id;
         });
         Session::put('compare_cart', $ids);
     }
     // Find TourSchedules
     if (!empty($ids)) {
         $tour_schedules = \App\TourSchedule::with('tour', 'tour.travel_agent', 'tour.travel_agent.images')->whereIn('id', $ids)->published()->orderBy('departure')->get();
     } else {
         $tour_schedules = new Collection();
     }
     return Response::json(['data' => $tour_schedules->toArray()], 200);
 }
Ejemplo n.º 3
0
 function compare_tour()
 {
     // dd(Session::get('compare_cart'));
     if (Session::has('compare_cart')) {
         $ids = Session::get('compare_cart', []);
         foreach ($ids as $k => $v) {
             if (is_null($v) || !$v) {
                 unset($ids[$k]);
             }
         }
         Session::put('compare_cart', $ids);
     }
     $this->layout->basic->compare_cart = \App\TourSchedule::with('tour', 'tour.travel_agent', 'tour.travel_agent.images')->whereIn('id', $ids)->published()->orderBy('departure')->get();
 }
Ejemplo n.º 4
0
 public function compare($id_list = null)
 {
     if (!is_null($id_list)) {
         $ids = explode(',', $id_list);
     } elseif (Session::has('compare_cart')) {
         $ids = Session::get('compare_cart');
     } else {
         return App::abort(404);
     }
     // get data
     $tour_schedules = \App\TourSchedule::whereIn('id', $ids)->get();
     $tour_schedules->load('tour', 'tour.travel_agent', 'tour.travel_agent.images');
     if (count($ids) != $tour_schedules->count()) {
         return App::abort(404);
     }
     foreach ($tour_schedules as $x) {
         $titles[] = $x->tour->name . ' ' . $x->departure->format('d-M-Y') . ($x->departure_until ? ' - ' . $x->departure_until->format('d-M-Y') : '') . ' (' . $x->tour->travel_agent->name . ')';
     }
     // ------------------------------------------------------------------------------------------------------------
     // SHOW DISPLAY
     // ------------------------------------------------------------------------------------------------------------
     $this->layout->page = view($this->page_base_dir . 'tour_compare');
     $this->layout->page->tour_schedules = $tour_schedules;
     $this->layout->page->option_list = $this->option_list;
     $this->layout->page->tour_shortcut = $this->tour_shortcut;
     // search tour
     $this->layout->page->all_travel_agents = $this->all_travel_agents;
     $this->layout->page->all_destinations = $this->all_destinations;
     $this->layout->page->departure_list = $this->departure_list;
     $this->layout->page->budget_list = $this->budget_list;
     $this->layout->title = "Perbandingan Tour " . implode(', ', $titles) . ' - Capcus.id';
     $this->layout->og['title'] = $this->layout->title;
     $this->layout->og['type'] = 'website';
     $this->layout->og['image'] = $tour_schedules->count() ? $tour_schedules->first()->tour->places->first()->images->where('name', 'LargeImage')->first()->path : '';
     $this->layout->og['image:type'] = 'jpg';
     $this->layout->og['image:width'] = 800;
     $this->layout->og['image:height'] = 600;
     return $this->layout;
 }
Ejemplo n.º 5
0
 public function index()
 {
     // ------------------------------------------------------------------------------------------------------------
     // QUERY HEADLINE
     // ------------------------------------------------------------------------------------------------------------
     $headlines = Cache::remember('current_headline', 60, function () {
         return \App\Headline::activeOn(\Carbon\Carbon::now())->orderBy('priority')->get();
     });
     $headlines = $headlines->sortBy(function ($headline) {
         return rand(0, 1000);
     });
     // ------------------------------------------------------------------------------------------------------------
     // QUERY HOME GRID
     // ------------------------------------------------------------------------------------------------------------
     $homegrids = Cache::remember('current_homegrids', 60, function () {
         $homegrids = \App\HomegridSetting::orderBy('name')->get();
         // get upcoming package schedules
         $homegrid_destination_ids = new Collection();
         foreach ($homegrids as $k => $v) {
             if (str_is('destination', $v->type)) {
                 $homegrid_destination_ids->push($v->destination);
             }
         }
         //
         if ($homegrid_destination_ids->count()) {
             $homegrid_destinations = \App\Destination::with('tours', 'tours.schedules')->whereIn('id', $homegrid_destination_ids)->get();
             foreach ($homegrids as $k => $v) {
                 $homegrids[$k]->destination_detail = $homegrid_destinations->find($v->destination);
                 if (str_is('destination', $v->type)) {
                     $homegrids[$k]->destination_detail->total_upcoming_schedules;
                 }
             }
         }
         return $homegrids;
     });
     // ------------------------------------------------------------------------------------------------------------
     // QUERY PAKET PROMO
     // ------------------------------------------------------------------------------------------------------------
     // $promo_tours = Cache::remember('8_upcoming_promo_tours', 30, function(){
     // 	return \App\TourSchedule::with('tour', 'tour.places', 'tour.places.images' ,'tour.destinations', 'tour.destinations.images', 'tour.travel_agent', 'tour.travel_agent.images', 'tour.schedules', 'tour.images')
     // 								->published()
     // 								->promo()
     // 								->scheduledBetween(\Carbon\Carbon::now(), \Carbon\Carbon::now()->addYears(5))
     // 								->orderby('departure')
     // 								->limit(8)
     // 								->select('tour_schedules.*')
     // 								->join('tours', 'tours.id', '=', 'tour_schedules.tour_id')
     // 								->join('travel_agencies', 'travel_agencies.id', '=', 'tours.travel_agent_id')
     // 								->groupBy('tours.travel_agent_id')
     // 								->get();
     // });
     // ------------------------------------------------------------------------------------------------------------
     // QUERY PAKET TOUR TERBARU
     // ------------------------------------------------------------------------------------------------------------
     $latest_tours = Cache::remember('8_latest_tours_by_different_travel_agent', 30, function () {
         $all_latest_tours = \App\Tour::with('destinations', 'schedules', 'destinations.images', 'places', 'places.images', 'travel_agent', 'travel_agent.images', 'images')->has('schedules')->select('tours.*')->join('travel_agencies', 'travel_agencies.id', '=', 'travel_agent_id')->published()->latest('tours.created_at')->limit(30)->get();
         $latest_tours = [];
         foreach ($all_latest_tours as $x) {
             if (!$latest_tours[$x->travel_agent_id] && count($latest_tours) <= 8) {
                 $latest_tours[$x->travel_agent_id] = $x;
             }
         }
         $converted_to_collection = new Collection();
         foreach ($latest_tours as $x) {
             $converted_to_collection->push($x);
         }
         return $converted_to_collection;
     });
     // ------------------------------------------------------------------------------------------------------------
     // TOP DESTINATION
     // ------------------------------------------------------------------------------------------------------------
     $top_destinations = Cache::remember('8_top_destination_in_6_months', 30, function () {
         $destinations = \App\Destination::with('images')->TopDestination(\Carbon\Carbon::now(), \Carbon\Carbon::now()->addMonth(6))->limit(8)->get();
         foreach ($destinations as $k => $v) {
             $destinations[$k]->total_upcoming_schedules;
         }
         return $destinations;
     });
     // ------------------------------------------------------------------------------------------------------------
     // TOTAL UPCOMING TOUR
     // ------------------------------------------------------------------------------------------------------------
     $total_upcoming_tours = Cache::remember('total_upcoming_tour_in_5_years', 60, function () {
         return \App\TourSchedule::scheduledBetween(\Carbon\Carbon::now(), \Carbon\Carbon::now()->addYear(5))->count();
     });
     // ------------------------------------------------------------------------------------------------------------
     // SHOW DISPLAY
     // ------------------------------------------------------------------------------------------------------------
     $this->layout->page = view($this->page_base_dir . 'home');
     $this->layout->page->headlines = $headlines;
     $this->layout->page->homegrids = $homegrids;
     $this->layout->page->latest_tours = $latest_tours;
     $this->layout->page->promo_tours = $promo_tours;
     $this->layout->page->total_upcoming_tours = $total_upcoming_tours;
     $this->layout->page->top_destinations = $top_destinations;
     // search tour
     $this->layout->page->all_travel_agents = $this->all_travel_agents;
     $this->layout->page->all_destinations = $this->all_destinations;
     $this->layout->page->departure_list = $this->departure_list;
     $this->layout->page->budget_list = $this->budget_list;
     $this->layout->page->place_list = $this->place_list;
     $this->layout->page->tour_shortcut = $this->tour_shortcut;
     //
     $this->layout->title = "Capcus.id - Cari paket tour jadi mudah";
     $this->layout->og['title'] = $this->layout->title;
     $this->layout->og['type'] = 'website';
     $this->layout->og['image'] = asset('images/logo-black.png');
     $this->layout->og['image:type'] = 'image/png';
     $this->layout->og['image:width'] = 275;
     $this->layout->og['image:height'] = 121;
     return $this->layout;
 }
Ejemplo n.º 6
0
 public function show($destination_slug, $place_slug)
 {
     // ------------------------------------------------------------------------------------------------------------
     // DETAIL PLACE
     // ------------------------------------------------------------------------------------------------------------
     $place = Place::inDestinationByPath(str_replace(',', \App\Destination::getDelimiter(), $destination_slug))->slugIs($place_slug)->published()->first();
     $place->load('images', 'destination');
     if (!$place) {
         \App::abort(404);
     }
     // ------------------------------------------------------------------------------------------------------------
     // OTHER PLACE FROM THE SAME DESTINATION
     // ------------------------------------------------------------------------------------------------------------
     $other_places = Cache::remember('other_place_in_' . $place->destination->id, 60, function () use($destination_slug, $place) {
         $other_places = Place::inDestinationByPath(str_replace(',', \App\Destination::getDelimiter(), $destination_slug))->where('id', '!=', $place->id)->published()->limit(8)->get();
         $other_places->load('images', 'destination');
         return $other_places;
     });
     // ------------------------------------------------------------------------------------------------------------
     // PAKET TOUR KE TEMPAT INI
     // ------------------------------------------------------------------------------------------------------------
     $tour_schedules = Cache::remember('upcoming_tour_to_place_' . $place->id, 60, function () use($place) {
         $tour_schedules = \App\TourSchedule::published()->whereHas('tour', function ($q) use($place) {
             $q->inPlaceByIds($place->id);
         })->scheduledBetween(\Carbon\Carbon::now(), \Carbon\Carbon::now()->addYear(1))->limit(5)->oldest('departure')->get();
         $tour_schedules->load('tour', 'tour.travel_agent', 'tour.travel_agent.images', 'tour.travel_agent.active_packages', 'tour.places', 'tour.options', 'tour.destinations');
         return $tour_schedules;
     });
     // ------------------------------------------------------------------------------------------------------------
     // SHOW DISPLAY
     // ------------------------------------------------------------------------------------------------------------
     $this->layout->page = view($this->page_base_dir . 'place_detail');
     $this->layout->page->place = $place;
     $this->layout->page->other_places = $other_places;
     $this->layout->page->tour_schedules = $tour_schedules;
     $this->layout->page->option_list = $this->option_list;
     $this->layout->title = $place->name . ' - Capcus.id';
     $this->layout->og['title'] = $this->layout->title;
     $this->layout->og['type'] = 'article';
     $this->layout->og['image'] = $place->images->where('name', 'Gallery1')->path;
     $this->layout->og['image:type'] = pathinfo('images/' . $this->layout->og['image'], PATHINFO_EXTENSION);
     $this->layout->og['image:width'] = 600;
     $this->layout->og['image:height'] = 400;
     return $this->layout;
 }