Example #1
0
 public function getCreate($data = null)
 {
     // ------------------------------------------------------------------------------------------------------------
     // GET TRAVEL AGENTS
     // ------------------------------------------------------------------------------------------------------------
     $travel_agents = \App\TravelAgent::orderBy('name')->get();
     // ------------------------------------------------------------------------------------------------------------
     // GET DESTINATIONS
     // ------------------------------------------------------------------------------------------------------------
     $destinations = \App\Destination::orderBy('path')->get();
     // ------------------------------------------------------------------------------------------------------------
     // GET PLACES
     // ------------------------------------------------------------------------------------------------------------
     $places = \App\Place::orderBy('long_name')->get();
     // ------------------------------------------------------------------------------------------------------------
     // GET TOUR OPTIONS
     // ------------------------------------------------------------------------------------------------------------
     $tour_options = \App\TourOption::orderBy('name')->get();
     // ------------------------------------------------------------------------------------------------------------
     // GET TAGS
     // ------------------------------------------------------------------------------------------------------------
     $tag_list = \App\Tag::orderBy('tag')->get();
     // ------------------------------------------------------------------------------------------------------------
     // SHOW DISPLAY
     // ------------------------------------------------------------------------------------------------------------
     $this->layout->page = view($this->page_base_dir . 'create')->with('route_name', $this->route_name)->with('view_name', $this->view_name);
     $this->layout->page->data = $data;
     $this->layout->page->travel_agents = $travel_agents;
     $this->layout->page->destinations = $destinations;
     $this->layout->page->places = $places;
     $this->layout->page->tour_options = $tour_options;
     $this->layout->page->tag_list = $tag_list;
     $this->layout->page->required_images = $this->required_images;
     return $this->layout;
 }
Example #2
0
 function init_search_tour()
 {
     // ------------------------------------------------------------------------------------------------------------
     // GET TRAVEL AGENT
     // ------------------------------------------------------------------------------------------------------------
     $this->all_travel_agents = Cache::remember('all_travel_agent_list', 60, function () {
         return TravelAgent::orderby('name')->get();
     });
     // ------------------------------------------------------------------------------------------------------------
     // GET DESTINATION
     // ------------------------------------------------------------------------------------------------------------
     $this->all_destinations = Cache::remember('all_destination_list', 60, function () {
         return Destination::orderby('name')->get();
     });
     // ------------------------------------------------------------------------------------------------------------
     // GET DEPARTURE LISTS
     // ------------------------------------------------------------------------------------------------------------
     $month = ['', 'Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember'];
     $now = \Carbon\Carbon::now();
     $departure_list = [];
     for ($i = 1; $i <= 12; $i++) {
         $departure_list[$now->year . str_pad($now->month, '2', '0', STR_PAD_LEFT)] = $month[$now->month] . ' ' . $now->year;
         $now->addMonth();
     }
     $this->departure_list = $departure_list;
     // ------------------------------------------------------------------------------------------------------------
     // GET BUDGET
     // ------------------------------------------------------------------------------------------------------------
     $this->budget_list = [0 => "Semua budget", '0-1000000' => "Di bawah Rp. 1.000.000", '1000000-2500000' => "Rp. 1.000.000 - Rp. 2.500.000", '2500000-5000000' => "Rp. 2.500.000 - Rp. 5.000.000", '5000000-10000000' => "Rp. 5.000.000 - Rp. 10.000.000", '10000000-20000000' => "Rp. 10.000.000 - Rp. 20.000.000", '20000000' => "Rp. 20.000.000 ke atas"];
     // ------------------------------------------------------------------------
     // TOUR OPTIONS
     // ------------------------------------------------------------------------
     $this->option_list = Cache::remember('all_option_list', 120, function () {
         return \App\TourOption::orderBy('name')->get();
     });
     // ------------------------------------------------------------------------
     // SHORTCUT TOUR LIST
     // ------------------------------------------------------------------------
     $this->tour_shortcut['destinations']['Eropa Barat'] = route('web.tour', ['travel_agent' => 'semua-travel-agent', 'destination' => 'eropa,eropa-barat']);
     $this->tour_shortcut['destinations']['Eropa Timur'] = route('web.tour', ['travel_agent' => 'semua-travel-agent', 'destination' => 'eropa,eropa-timur']);
     $this->tour_shortcut['destinations']['Asia'] = route('web.tour', ['travel_agent' => 'semua-travel-agent', 'destination' => 'asia']);
     $this->tour_shortcut['destinations']['Australia'] = route('web.tour', ['travel_agent' => 'semua-travel-agent', 'destination' => 'australia']);
     $this->tour_shortcut['destinations']['Amerika'] = route('web.tour', ['travel_agent' => 'semua-travel-agent', 'destination' => 'amerika']);
     $this->tour_shortcut['destinations']['China'] = route('web.tour', ['travel_agent' => 'semua-travel-agent', 'destination' => 'asia,china']);
     $this->tour_shortcut['destinations']['Domestik'] = route('web.tour', ['travel_agent' => 'semua-travel-agent', 'destination' => 'domestik']);
     $this->tour_shortcut['tags']['#Religius'] = route('web.tour.tag', ['tag' => 'religius']);
     $this->tour_shortcut['tags']['#Adventure'] = route('web.tour.tag', ['tag' => 'adventure']);
     $this->tour_shortcut['tags']['#HoneyMoon'] = route('web.tour.tag', ['tag' => 'honeymoon']);
     ksort($this->tour_shortcut['destinations']);
     ksort($this->tour_shortcut['tags']);
 }
 public function getCreate($data = null)
 {
     // ------------------------------------------------------------------------------------------------------------
     // DESTINATIONS
     // ------------------------------------------------------------------------------------------------------------
     $travel_agents = \App\TravelAgent::orderBy('name')->get();
     // ------------------------------------------------------------------------------------------------------------
     // SHOW DISPLAY
     // ------------------------------------------------------------------------------------------------------------
     $this->layout->page = view($this->page_base_dir . 'create')->with('route_name', $this->route_name)->with('view_name', $this->view_name);
     $this->layout->page->data = $data;
     $this->layout->page->travel_agents = $travel_agents;
     $this->layout->page->required_images = $this->required_images;
     $this->layout->page->destinations = $destinations;
     return $this->layout;
 }
 public function HeadlineCreate($data = null)
 {
     $this->required_images = ['LargeImage' => 'Large Image (1400x500px)'];
     // ------------------------------------------------------------------------------------------------------------
     // DESTINATIONS
     // ------------------------------------------------------------------------------------------------------------
     $travel_agents = \App\TravelAgent::orderBy('name')->get();
     // ------------------------------------------------------------------------------------------------------------
     // SHOW DISPLAY
     // ------------------------------------------------------------------------------------------------------------
     $this->layout->page = view($this->page_base_dir . 'headlines.create')->with('route_name', $this->route_name)->with('view_name', $this->view_name);
     $this->layout->page->data = $data;
     $this->layout->page->travel_agents = $travel_agents;
     $this->layout->page->required_images = $this->required_images;
     $this->layout->page->destinations = $destinations;
     return $this->layout;
 }
Example #5
0
 public function lists($travel_agent = null, $tujuan = null, $keberangkatan = null, $budget = null)
 {
     // ------------------------------------------------------------------------
     // REDIRECT IF REQUEST URL
     // ------------------------------------------------------------------------
     $filters = Input::only('travel_agent', 'tujuan', 'keberangkatan_sejak', 'keberangkatan_hingga', 'budget');
     if (!empty(array_filter($filters))) {
         $filters = array_filter($filters);
         // Travel Agent
         if (!$filters['travel_agent']) {
             $filters['travel_agent'] = 'semua-travel-agent';
         }
         // Tujuan
         if (!$filters['tujuan']) {
             $filters['tujuan'] = 'semua-tujuan';
         }
         // Keberangkatan
         if ($filters['keberangkatan_sejak'] && $filters['keberangkatan_hingga']) {
             try {
                 $tmp1 = \Carbon\Carbon::createFromFormat('d-m-Y', $filters['keberangkatan_sejak']);
                 $tmp2 = \Carbon\Carbon::createFromFormat('d-m-Y', $filters['keberangkatan_hingga']);
             } catch (Exception $e) {
                 return App::abort(404);
             }
             if ($tmp1->lt($tmp2)) {
                 $keberangkatan_str = $tmp1->format('Ymd') . '-' . $tmp2->format('Ymd');
             } else {
                 $keberangkatan_str = $tmp2->format('Ymd') . '-' . $tmp1->format('Ymd');
             }
         } else {
             $keberangkatan_str = "semua-keberangkatan";
         }
         // Tujuan
         if (!$filters['budget']) {
             $filters['budget'] = 'semua-budget';
         }
         return redirect()->to(route('web.tour', ['travel_agent' => $filters['travel_agent'], 'tujuan' => $filters['tujuan'], 'keberangkatan' => $keberangkatan_str, 'budget' => $filters['budget']]) . (Input::has('place') ? '?place=' . Input::get('place') : ''));
     } else {
         $filters['travel_agent'] = $travel_agent;
         $filters['tujuan'] = $tujuan;
         $filters['keberangkatan'] = $keberangkatan;
         $filters['budget'] = $budget;
         $filters['place'] = Input::get('place');
         // TRAVEL AGENT
         if (str_is(strtolower($filters['travel_agent']), 'semua-travel-agent')) {
             unset($filters['travel_agent']);
         } else {
             if ($filters['travel_agent']) {
                 $filters['travel_agent'] = TravelAgent::SlugIs($filters['travel_agent'])->first();
                 if (!$filters['travel_agent']) {
                     return App::abort(404);
                 }
             }
             $this->layout->basic->filters['travel_agent'] = $filters['travel_agent'];
         }
         // TUJUAN
         if (str_is(strtolower($filters['tujuan']), 'semua-tujuan')) {
             unset($filters['tujuan']);
         } else {
             $tujuan_tree = Destination::findPath(str_replace(',', Destination::getDelimiter(), $filters['tujuan'] . '*'))->get();
             if (!$tujuan_tree) {
                 return App::abort(404);
             }
             // get tujuan object
             foreach ($tujuan_tree as $x) {
                 if (str_is($filters['tujuan'], $x->path_slug)) {
                     $filters['tujuan'] = $x;
                     break;
                 }
             }
             $this->layout->basic->filters['tujuan'] = $filters['tujuan'];
         }
         // KEBERANGKATAN
         if (str_is(strtolower($filters['keberangkatan']), 'semua-keberangkatan')) {
             unset($filters['keberangkatan']);
             $filters['keberangkatan']['from'] = \Carbon\Carbon::now();
             $filters['keberangkatan']['to'] = \Carbon\Carbon::now()->addYear(1);
         } elseif ($filters['keberangkatan']) {
             list($keberangkatan_from, $keberangkatan_to) = explode('-', $filters['keberangkatan']);
             try {
                 $keberangkatan_from = \Carbon\Carbon::createFromFormat('Ymd', $keberangkatan_from);
                 $keberangkatan_to = \Carbon\Carbon::createFromFormat('Ymd', $keberangkatan_to);
                 if ($keberangkatan_from->gt($keberangkatan_to)) {
                     $tmp = $keberangkatan_from;
                     $keberangkatan_from = $keberangkatan_to;
                     $keberangkatan_to = $tmp;
                 }
             } catch (Exception $e) {
                 App::abort(404);
             }
             unset($filters['keberangkatan']);
             $filters['keberangkatan']['from'] = $keberangkatan_from;
             $filters['keberangkatan']['to'] = $keberangkatan_to;
             $this->layout->basic->filters['keberangkatan'] = $filters['keberangkatan'];
         } else {
             $filters['keberangkatan']['from'] = \Carbon\Carbon::now();
             $filters['keberangkatan']['to'] = \Carbon\Carbon::now()->addYear(1);
         }
         // BUDGET
         if (str_is(strtolower($filters['budget']), 'semua-budget')) {
             unset($filters['budget']);
         } else {
             list($budget_min, $budget_max) = explode('-', $filters['budget']);
             if ($budget_min * 1 < 0) {
                 return App::abort(404);
             }
             if (!is_null($budget_max) && ($budget_max <= 0 || $budget_max <= $budget_min)) {
                 return App::abort(404);
             }
             unset($filters['budget']);
             $filters['budget'] = ['min' => $budget_min, 'max' => $budget_max];
             $this->layout->basic->filters['budget'] = $filters['budget'];
         }
         // PLACE
         if ($filters['place']) {
             $filters['place'] = \App\Place::slugIs($filters['place'])->first();
             if (!$filters['place']) {
                 return App::abort(404);
             }
         }
     }
     // ------------------------------------------------------------------------
     // QUERY
     // ------------------------------------------------------------------------
     $max_data = 50;
     $results = Cache::remember('tour_schedules_' . serialize($filters), 30, function () use($filters, $tujuan_tree, $max_data) {
         $results = $this->dispatch(new FindPublishedTourSchedules($filters['keberangkatan']['from'], $filters['keberangkatan']['to'], $tujuan_tree ? $tujuan_tree->lists('id') : null, $filters['budget']['min'] * 1, $filters['budget']['max'] ? $filters['budget']['max'] * 1 : 99999999999.0, $filters['travel_agent']->id, $filters['place']->slug, 0, $max_data, true));
         $results['data']->load('tour', 'tour.travel_agent', 'tour.travel_agent.active_packages', 'tour.places', 'tour.destinations', 'tour.travel_agent.images', 'tour.options');
         return $results;
     });
     $tour_schedules_count = $results['count'];
     $tour_schedules = $results['data'];
     // SORT BY TRAVEL AGENT PRIORITY
     // $tour_schedules = $tour_schedules->sortBy(function($data, $key){
     // 	return str_pad($data->tour->travel_agent->active_packages[0]->priority ? $data->tour->travel_agent->active_packages[0]->priority * -1 : 0, 2, 0, STR_PAD_LEFT) . $data->departure;
     // });
     // ------------------------------------------------------------------------
     // PREPARE FILTERS FOR RESULTS
     // ------------------------------------------------------------------------
     $filter_schedules = [];
     // durations
     foreach ($tour_schedules as $schedule) {
         $filter_schedules['durations'][$schedule->tour->duration_day * 1] = $schedule->tour->duration_day . 'D/' . $schedule->tour->duration_night . 'N';
         $filter_schedules['travel_agents'][$schedule->tour->travel_agent->id] = $schedule->tour->travel_agent->name;
         if (!$filter_schedules['price']['min'] || $filter_schedules['price']['min'] > $schedule->discounted_price) {
             $filter_schedules['price']['min'] = $schedule->discounted_price;
         }
         if ($filter_schedules['price']['max'] < $schedule->discounted_price) {
             $filter_schedules['price']['max'] = $schedule->discounted_price;
         }
     }
     ksort($filter_schedules['durations']);
     asort($filter_schedules['travel_agents']);
     // ------------------------------------------------------------------------------------------------------------
     // SHOW DISPLAY
     // ------------------------------------------------------------------------------------------------------------
     $this->layout->page = view($this->page_base_dir . 'tours');
     $this->layout->page->travel_agent = $travel_agent;
     $this->layout->page->tujuan_tree = $tujuan_tree;
     $this->layout->page->max_data = $max_data;
     $this->layout->page->filters = $filters;
     $this->layout->page->filter_schedules = $filter_schedules;
     $this->layout->page->option_list = $this->option_list;
     $this->layout->page->tour_schedules = $tour_schedules;
     $this->layout->page->tour_schedules_count = $tour_schedules_count;
     $this->layout->page->other_tours = $other_tours;
     // 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->tour_shortcut = $this->tour_shortcut;
     //
     $this->layout->title = "Paket Tour " . ($filters['tujuan'] ? 'ke ' . $filters['tujuan']->name : '') . ($filters['travel_agent'] ? ' oleh ' . $filters['travel_agent']->name : '') . ($filters['keberangkatan']['from'] && $filters['keberangkatan']['to'] ? ' keberangkatan ' . $filters['keberangkatan']['from']->format('d-m-Y') . ' s/d ' . $filters['keberangkatan']['to']->format('d-m-Y') : '') . ($filters['budget']['min'] ? ' harga ' . $filters['budget']['min'] . '-' . $filters['budget']['max'] : '') . ' - 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;
 }