Esempio n. 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;
 }
Esempio n. 2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // ------------------------------------------------------------------------------------------------------------
     // GET HEADLINE
     // ------------------------------------------------------------------------------------------------------------
     $headlines = \App\Headline::with('travel_agent')->activeOn(\Carbon\Carbon::now())->orderBy('priority')->get();
     $headlines = $headlines->sortByDesc(function ($data) {
         return $data->travel_agent->active_packages[0]->priority;
     });
     // ------------------------------------------------------------------------------------------------------------
     // GET HOMEGRID
     // ------------------------------------------------------------------------------------------------------------
     $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);
         }
     }
     // ------------------------------------------------------------------------------------------------------------
     // QUERY PAKET PROMO TERBARU
     // ------------------------------------------------------------------------------------------------------------
     $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(8)->groupBy('travel_agent_id')->get();
     // ------------------------------------------------------------------------------------------------------------
     // GET BLOG TERBARU
     // ------------------------------------------------------------------------------------------------------------
     $articles = Article::with('images')->published()->latest('published_at')->take(6)->get();
     // ------------------------------------------------------------------------------------------------------------
     // GET USER
     // ------------------------------------------------------------------------------------------------------------
     $total_subscriber = \App\Subscriber::active()->count();
     $this->info(' ---------------------------------------------------------------------------------------------- ');
     $this->info(' BLAST NEWSLETTER ');
     $this->info(' ---------------------------------------------------------------------------------------------- ');
     $this->info(' * Sending Newsletter to ' . $total_subscriber . ' subscribers');
     \App\Subscriber::with('user')->active()->orderby('id')->chunk(100, function ($subscribers) {
         foreach ($subscribers as $subscriber) {
             Mail::queue('web.v4.emails.newsletters.weekly', ['headlines' => $headlines, 'homegrids' => $homegrids, 'tours' => $tours, 'articles' => $articles, 'subscriber' => $subscriber], function ($m) use($subscriber) {
                 $m->to($subscriber->email, $subscriber->user ? $subscriber->user->name : $subscriber->email)->subject('CAPCUS.id - Newsletter Edisi ' . \Carbon\Carbon::now()->year . '.' . \Carbon\Carbon::now()->format('W'));
             });
             $this->info(' * Newsletter sent to ' . $subscriber->email . ' *');
         }
     });
     $this->info(' ---------------------------------------------------------------------------------------------- ');
     $this->info(' BLAST NEWSLETTER COMPLETED');
     $this->info(' ---------------------------------------------------------------------------------------------- ');
 }
Esempio n. 3
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']);
 }
Esempio n. 4
0
 public function getCreate($data = null)
 {
     // ------------------------------------------------------------------------------------------------------------
     // DESTINATIONS
     // ------------------------------------------------------------------------------------------------------------
     $destinations = \App\Destination::orderBy('path')->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->required_images = $this->required_images;
     $this->layout->page->destinations = $destinations;
     return $this->layout;
 }
Esempio n. 5
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $top_tours = DB::select("select d.id, count(ts.id) as aggregate\n\t\t\t\t\t\t    \tfrom destinations d \n                                join destination_tour dt on dt.destination_id = d.id\n                                join tours t on t.id = dt.tour_id\n                                join tour_schedules ts on ts.tour_id = t.id\n\t\t\t\t\t\t    \tgroup by d.id\n\t\t\t\t\t\t    \torder by aggregate desc\n\t\t\t\t\t\t    \tlimit 12");
     foreach ($top_tours as $k => $x) {
         $destination = \App\Destination::find($x->id);
         $headline = new \App\HomegridSetting(['name' => 'homegrid_' . ($k + 1), 'since' => \Carbon\Carbon::now()]);
         $headline->type = 'destination';
         $headline->is_featured = rand(0, 100) < 30 ? true : false;
         $headline->title = $destination->name;
         $headline->destination = $destination->id;
         $headline->image_url = 'http://localhost:8000/images/43/' . ($k + 1) . '.jpg';
         if (!$headline->save()) {
             dd($headline->getErrors());
         }
     }
 }
Esempio n. 6
0
 public function getCreate($data = null)
 {
     // ------------------------------------------------------------------------------------------------------------
     // DESTINATION
     // ------------------------------------------------------------------------------------------------------------
     $destinations = \App\Destination::orderBy(\App\Destination::getPathField());
     // ------------------------------------------------------------------------------------------------------------
     // TAG
     // ------------------------------------------------------------------------------------------------------------
     $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->required_images = $this->required_images;
     $this->layout->page->destinations = $destinations;
     $this->layout->page->tag_list = $tag_list;
     return $this->layout;
 }
Esempio n. 7
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Create tags
     //
     for ($i = 1; $i < 500; $i++) {
         $destination = \App\Destination::whereNotNull('parent_id')->orderByRaw('RAND()')->first();
         $place_name = 'Place ' . $destination->name . ' ' . $i;
         $place = new \App\Place(['destination_id' => $destination->id, 'name' => $place_name, 'slug' => str_slug($place_name), 'long_name' => $place_name . ', ' . $destination->name, 'summary' => 'Lorem ipsum Voluptate veniam quis in mollit veniam consequat veniam irure est elit in esse dolore nisi in nulla sint laboris aliqua eu aliquip do.', 'content' => 'Lorem ipsum Aliquip aliqua anim in et in labore ut laboris cupidatat dolor dolor aliquip quis aliqua consectetur sit aliquip enim Ut aliquip nulla id ea eu exercitation dolor id cupidatat anim ut aliqua qui amet nisi in aliquip ad sed Excepteur ullamco ut eiusmod cupidatat proident reprehenderit eiusmod aliqua Ut officia Duis aliqua ullamco non reprehenderit ea in velit ad mollit sit consequat culpa consectetur in mollit in aute labore nostrud ea aute Excepteur dolore adipisicing voluptate consequat qui in ea amet aute culpa elit proident dolore mollit tempor non dolor elit aliquip Ut adipisicing tempor elit dolore elit dolor occaecat dolore quis eiusmod sit id exercitation consequat occaecat elit ea consequat veniam Ut ut Excepteur tempor quis anim commodo nisi in do officia Ut enim officia ullamco Ut aute non Excepteur ut ut eu elit est aute ut Duis mollit aliqua laborum ea magna Ut eiusmod velit labore eu qui do officia incididunt non ea in quis in ullamco reprehenderit culpa labore dolore elit deserunt culpa ad laborum cillum sint nisi dolore ad velit aliqua consequat laboris voluptate aute ex dolor minim commodo labore incididunt veniam sunt elit amet dolore aliquip eu nostrud dolor non irure ea aute tempor laborum incididunt sed mollit enim fugiat irure fugiat aute anim do in velit culpa dolore Duis labore culpa laborum Excepteur cillum cupidatat ut dolore esse laborum elit eiusmod officia commodo consectetur consequat aute ea id commodo exercitation nisi occaecat est deserunt dolor proident exercitation ut nostrud cupidatat fugiat minim dolore veniam deserunt nostrud adipisicing minim cupidatat.', 'published_at' => \Carbon\Carbon::now()]);
         if (!$place->save()) {
             dd($place->getErrors());
         }
         $img = rand(1, 12);
         $place->images()->saveMany([new Image(['name' => 'Gallery1', 'path' => 'http://localhost:8000/images/43/' . max(1, ($img + 1) % 12) . '.jpg', 'title' => $place->name, 'description' => $place->summary]), new Image(['name' => 'Gallery2', 'path' => 'http://localhost:8000/images/43/' . max(1, ($img + 2) % 12) . '.jpg', 'title' => $place->name, 'description' => $place->summary]), new Image(['name' => 'Gallery3', 'path' => 'http://localhost:8000/images/43/' . max(1, ($img + 3) % 12) . '.jpg', 'title' => $place->name, 'description' => $place->summary]), new Image(['name' => 'Gallery4', 'path' => 'http://localhost:8000/images/43/' . max(1, ($img + 4) % 12) . '.jpg', 'title' => $place->name, 'description' => $place->summary]), new Image(['name' => 'Gallery5', 'path' => 'http://localhost:8000/images/43/' . max(1, ($img + 5) % 12) . '.jpg', 'title' => $place->name, 'description' => $place->summary])]);
         $tag_count = rand(1, 3);
         $tags = [];
         for ($j = 1; $j < $tag_count; $j++) {
             $tags[] = rand(3, 10);
         }
         $place->tags()->sync($tags);
     }
 }
Esempio n. 8
0
 public function getDatatable()
 {
     $booking = Destination::select(array('id', 'image', 'tujuan'));
     return Datatables::of($booking)->addColumn('image', function ($booking) {
         return '<img src="../' . $booking->image . '"class="img-responsive" width="50" height="50"></img>';
     })->addColumn('action', function ($booking) {
         return '<a href="destination/edit/' . $booking->id . '" class="btn btn-xs btn-primary">Edit</a> <a href="destination/delete/' . $booking->id . '" class="btn btn-xs btn-danger">Delete</a>';
     })->removeColumn('update_at')->make(true);
 }
 public function resorts()
 {
     $idPageResorts = 39;
     //este id es el id de la pagina en la base de datos en la tabla page con  campo id
     $page = Page::resort($this->resortId)->active()->id($idPageResorts)->with(['contents' => function ($query) {
         $query->where('lang_id', '=', $this->langId);
     }])->first();
     if ($page) {
         $page = $page->contents->first();
         $idStMaarten = 5;
         //este id es el id del destindo en la tabla destinatios
         $idCuracao = 6;
         //este id es el id del destindo en la tabla destinatios
         $destination1 = Destination::active()->id($idStMaarten)->with(['contents' => function ($query) {
             $query->select('destination_contents.destination_id', 'destination_contents.short_description', 'destination_contents.alt1');
             $query->where('lang_id', '=', $this->langId);
         }])->with(['resorts.contents' => function ($query) {
             $query->select('resort_contents.resort_id', 'resort_contents.short_description', 'resort_contents.short_offer', 'resort_contents.alt1');
             $query->where('lang_id', '=', $this->langId);
         }])->first();
         $destination2 = Destination::active()->id($idCuracao)->with(['contents' => function ($query) {
             $query->select('destination_contents.destination_id', 'destination_contents.short_description', 'destination_contents.alt1');
             $query->where('lang_id', '=', $this->langId);
         }])->with(['resorts.contents' => function ($query) {
             $query->select('resort_contents.resort_id', 'resort_contents.short_description', 'resort_contents.short_offer', 'resort_contents.alt1');
             $query->where('lang_id', '=', $this->langId);
         }])->first();
         //return dd($destination3->toArray());
         return View('pages.resorts', compact('page', 'destination1', 'destination2'));
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Destination::destroy($id);
 }
Esempio n. 11
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;
 }
Esempio n. 12
0
 public function getDestinationDetailAttribute()
 {
     if (!$this->attributes['destination_detail']) {
         $destination_id = $this->destination;
         $tmp = \App\Destination::find($destination_id);
         $this->attributes['destination_detail'] = $tmp;
     }
     return $this->attributes['destination_detail'];
 }
Esempio n. 13
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;
 }
Esempio n. 14
0
 protected function get_top_destinations()
 {
     // ------------------------------------------------------------------------------------------------------------
     // TOP DESTINATION
     // ------------------------------------------------------------------------------------------------------------
     return Cache::remember('get_top_destinations', 15, function () {
         return \App\Destination::with('images')->TopDestination(\Carbon\Carbon::now(), \Carbon\Carbon::now()->addMonth(6))->limit(6)->get();
     });
 }
 public function HomegridsEdit($homegrid_no)
 {
     // ------------------------------------------------------------------------------------------------------------
     // EDIT HOME GRID
     // ------------------------------------------------------------------------------------------------------------
     if (!$homegrid_no || !is_numeric($homegrid_no) || $homegrid_no < 1 || $homegrid_no > 12) {
         return App::abort(404);
     }
     // ------------------------------------------------------------------------------------------------------------
     // LOAD HOMEGRID
     // ------------------------------------------------------------------------------------------------------------
     $homegrid = HomegridSetting::homegrid($homegrid_no)->first();
     if (!$homegrid) {
         $homegrid = new HomegridSetting(['name' => 'homegrid_' . $homegrid_no, 'since' => \Carbon\Carbon::now()]);
     }
     // ------------------------------------------------------------------------------------------------------------
     // Destination List
     // ------------------------------------------------------------------------------------------------------------
     $destination_list = \App\Destination::orderBy('path')->get()->lists('path', 'id')->toArray();
     // ------------------------------------------------------------------------------------------------------------
     // TAG List
     // ------------------------------------------------------------------------------------------------------------
     $tag_list = \App\Tag::Has('tours')->orderBy('tag')->get()->lists('tag', 'id')->toArray();
     // ------------------------------------------------------------------------------------------------------------
     // SHOW DISPLAY
     // ------------------------------------------------------------------------------------------------------------
     $this->layout->page = view($this->page_base_dir . 'homegrids.create')->with('route_name', $this->route_name)->with('view_name', $this->view_name);
     $this->layout->page->homegrid = $homegrid;
     $this->layout->page->homegrid_no = $homegrid_no;
     $this->layout->page->homegrid_types = $this->homegrid_types;
     $this->layout->page->destination_list = $destination_list;
     $this->layout->page->tag_list = $tag_list;
     return $this->layout;
 }
Esempio n. 16
0
 public function getDestinations()
 {
     if (!empty($this->project_id)) {
         return \App\Destination::where('project_id', '=', $this->project_id)->orderBy('sort')->get(['title', 'email']);
     } else {
         return null;
     }
 }
Esempio n. 17
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;
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //
     // $destinations = [
     // 			['name' => 'Afrika', 'parent_name' => null],
     // 			['name' => 'Afrika Selatan', 'parent_name' => 'Afrika'],
     // 			['name' => 'Algeria', 'parent_name' => 'Afrika'],
     // 			['name' => 'Angola', 'parent_name' => 'Afrika'],
     // 			['name' => 'Benin', 'parent_name' => 'Afrika'],
     // 			['name' => 'Botswana', 'parent_name' => 'Afrika'],
     // 			['name' => 'Burkina Faso', 'parent_name' => 'Afrika'],
     // 			['name' => 'Burundi', 'parent_name' => 'Afrika'],
     // 			['name' => 'Chad', 'parent_name' => 'Afrika'],
     // 			['name' => 'Eritrea', 'parent_name' => 'Afrika'],
     // 			['name' => 'Ethiopia', 'parent_name' => 'Afrika'],
     // 			['name' => 'Gabon', 'parent_name' => 'Afrika'],
     // 			['name' => 'Gambia', 'parent_name' => 'Afrika'],
     // 			['name' => 'Ghana', 'parent_name' => 'Afrika'],
     // 			['name' => 'Guinea', 'parent_name' => 'Afrika'],
     // 			['name' => 'Guinea Khatulistiwa', 'parent_name' => 'Afrika'],
     // 			['name' => 'Guinea-Bissau', 'parent_name' => 'Afrika'],
     // 			['name' => 'Jibouti', 'parent_name' => 'Afrika'],
     // 			['name' => 'Kamerun', 'parent_name' => 'Afrika'],
     // 			['name' => 'Kenya', 'parent_name' => 'Afrika'],
     // 			['name' => 'Komoros', 'parent_name' => 'Afrika'],
     // 			['name' => 'Kongo', 'parent_name' => 'Afrika'],
     // 			['name' => 'Lesotho', 'parent_name' => 'Afrika'],
     // 			['name' => 'Liberia', 'parent_name' => 'Afrika'],
     // 			['name' => 'Libya', 'parent_name' => 'Afrika'],
     // 			['name' => 'Madagaskar', 'parent_name' => 'Afrika'],
     // 			['name' => 'Malawi', 'parent_name' => 'Afrika'],
     // 			['name' => 'Mali', 'parent_name' => 'Afrika'],
     // 			['name' => 'Maroko', 'parent_name' => 'Afrika'],
     // 			['name' => 'Mauritania', 'parent_name' => 'Afrika'],
     // 			['name' => 'Mauritius', 'parent_name' => 'Afrika'],
     // 			['name' => 'Mayotte', 'parent_name' => 'Afrika'],
     // 			['name' => 'Mesir', 'parent_name' => 'Afrika'],
     // 			['name' => 'Mozambique', 'parent_name' => 'Afrika'],
     // 			['name' => 'Namibia', 'parent_name' => 'Afrika'],
     // 			['name' => 'Niger', 'parent_name' => 'Afrika'],
     // 			['name' => 'Nigeria', 'parent_name' => 'Afrika'],
     // 			['name' => 'Pantai Gading', 'parent_name' => 'Afrika'],
     // 			['name' => 'Republik Afrika Tengah', 'parent_name' => 'Afrika'],
     // 			['name' => 'Republik Demokratik Kongo', 'parent_name' => 'Afrika'],
     // 			['name' => 'Rwanda', 'parent_name' => 'Afrika'],
     // 			['name' => 'Réunion', 'parent_name' => 'Afrika'],
     // 			['name' => 'Sahara Barat', 'parent_name' => 'Afrika'],
     // 			['name' => 'Saint Helena', 'parent_name' => 'Afrika'],
     // 			['name' => 'Sao Tome dan Principe', 'parent_name' => 'Afrika'],
     // 			['name' => 'Senegal', 'parent_name' => 'Afrika'],
     // 			['name' => 'Seychelles', 'parent_name' => 'Afrika'],
     // 			['name' => 'Sierra Leone', 'parent_name' => 'Afrika'],
     // 			['name' => 'Somalia', 'parent_name' => 'Afrika'],
     // 			['name' => 'Sudan', 'parent_name' => 'Afrika'],
     // 			['name' => 'Swaziland', 'parent_name' => 'Afrika'],
     // 			['name' => 'Tanjung Verde', 'parent_name' => 'Afrika'],
     // 			['name' => 'Tanzania', 'parent_name' => 'Afrika'],
     // 			['name' => 'Togo', 'parent_name' => 'Afrika'],
     // 			['name' => 'Tunisia', 'parent_name' => 'Afrika'],
     // 			['name' => 'Uganda', 'parent_name' => 'Afrika'],
     // 			['name' => 'Zambia', 'parent_name' => 'Afrika'],
     // 			['name' => 'Zimbabwe', 'parent_name' => 'Afrika'],
     // 			['name' => 'Amerika', 'parent_name' => null],
     // 			['name' => 'Amerika Serikat', 'parent_name' => 'Amerika'],
     // 			['name' => 'Anguilla', 'parent_name' => 'Amerika'],
     // 			['name' => 'Antigua dan Barbuda', 'parent_name' => 'Amerika'],
     // 			['name' => 'Antilles Belanda', 'parent_name' => 'Amerika'],
     // 			['name' => 'Argentina', 'parent_name' => 'Amerika'],
     // 			['name' => 'Aruba', 'parent_name' => 'Amerika'],
     // 			['name' => 'Bahamas', 'parent_name' => 'Amerika'],
     // 			['name' => 'Barbados', 'parent_name' => 'Amerika'],
     // 			['name' => 'Belize', 'parent_name' => 'Amerika'],
     // 			['name' => 'Bermuda', 'parent_name' => 'Amerika'],
     // 			['name' => 'Bolivia', 'parent_name' => 'Amerika'],
     // 			['name' => 'Brazil', 'parent_name' => 'Amerika'],
     // 			['name' => 'Chili', 'parent_name' => 'Amerika'],
     // 			['name' => 'Dominika', 'parent_name' => 'Amerika'],
     // 			['name' => 'Ekuador', 'parent_name' => 'Amerika'],
     // 			['name' => 'El Salvador', 'parent_name' => 'Amerika'],
     // 			['name' => 'Greenland', 'parent_name' => 'Amerika'],
     // 			['name' => 'Grenada', 'parent_name' => 'Amerika'],
     // 			['name' => 'Guadeloupe', 'parent_name' => 'Amerika'],
     // 			['name' => 'Guatemala', 'parent_name' => 'Amerika'],
     // 			['name' => 'Guyana', 'parent_name' => 'Amerika'],
     // 			['name' => 'Guyana Perancis', 'parent_name' => 'Amerika'],
     // 			['name' => 'Haiti', 'parent_name' => 'Amerika'],
     // 			['name' => 'Honduras', 'parent_name' => 'Amerika'],
     // 			['name' => 'Jamaika', 'parent_name' => 'Amerika'],
     // 			['name' => 'Kanada', 'parent_name' => 'Amerika'],
     // 			['name' => 'Kepulauan British Virgin', 'parent_name' => 'Amerika'],
     // 			['name' => 'Kepulauan Falkland', 'parent_name' => 'Amerika'],
     // 			['name' => 'Kepulauan Kayman', 'parent_name' => 'Amerika'],
     // 			['name' => 'Kepulauan Turks dan Caicos', 'parent_name' => 'Amerika'],
     // 			['name' => 'Kepulauan U.S. Virgin', 'parent_name' => 'Amerika'],
     // 			['name' => 'Kolombia', 'parent_name' => 'Amerika'],
     // 			['name' => 'Kosta Rika', 'parent_name' => 'Amerika'],
     // 			['name' => 'Kuba', 'parent_name' => 'Amerika'],
     // 			['name' => 'Martinique', 'parent_name' => 'Amerika'],
     // 			['name' => 'Mexico', 'parent_name' => 'Amerika'],
     // 			['name' => 'Montserrat', 'parent_name' => 'Amerika'],
     // 			['name' => 'Nicaragua', 'parent_name' => 'Amerika'],
     // 			['name' => 'Panama', 'parent_name' => 'Amerika'],
     // 			['name' => 'Paraguay', 'parent_name' => 'Amerika'],
     // 			['name' => 'Peru', 'parent_name' => 'Amerika'],
     // 			['name' => 'Puerto Riko', 'parent_name' => 'Amerika'],
     // 			['name' => 'Republik Dominika', 'parent_name' => 'Amerika'],
     // 			['name' => 'Saint Kitts dan Nevis', 'parent_name' => 'Amerika'],
     // 			['name' => 'Saint Pierre dan Miquelon', 'parent_name' => 'Amerika'],
     // 			['name' => 'Saint Vincent dan Grenadines', 'parent_name' => 'Amerika'],
     // 			['name' => 'Santa Lusia', 'parent_name' => 'Amerika'],
     // 			['name' => 'Suriname', 'parent_name' => 'Amerika'],
     // 			['name' => 'Trinidad dan Tobago', 'parent_name' => 'Amerika'],
     // 			['name' => 'Uruguay', 'parent_name' => 'Amerika'],
     // 			['name' => 'Venezuela', 'parent_name' => 'Amerika'],
     // 			['name' => 'Asia', 'parent_name' => null],
     // 			['name' => 'Afghanistan', 'parent_name' => 'Asia'],
     // 			['name' => 'Arab Saudi', 'parent_name' => 'Asia'],
     // 			['name' => 'Armenia', 'parent_name' => 'Asia'],
     // 			['name' => 'Azerbaijan', 'parent_name' => 'Asia'],
     // 			['name' => 'Bahrain', 'parent_name' => 'Asia'],
     // 			['name' => 'Bangladesh', 'parent_name' => 'Asia'],
     // 			['name' => 'Bhutan', 'parent_name' => 'Asia'],
     // 			['name' => 'Brunei', 'parent_name' => 'Asia'],
     // 			['name' => 'Cina', 'parent_name' => 'Asia'],
     // 			['name' => 'Filipina', 'parent_name' => 'Asia'],
     // 			['name' => 'Georgia', 'parent_name' => 'Asia'],
     // 			['name' => 'Hong Kong S.A.R., Cina', 'parent_name' => 'Asia'],
     // 			['name' => 'India', 'parent_name' => 'Asia'],
     // 			['name' => 'Indonesia', 'parent_name' => 'Asia'],
     // 			['name' => 'Iran', 'parent_name' => 'Asia'],
     // 			['name' => 'Iraq', 'parent_name' => 'Asia'],
     // 			['name' => 'Israel', 'parent_name' => 'Asia'],
     // 			['name' => 'Jepang', 'parent_name' => 'Asia'],
     // 			['name' => 'Kamboja', 'parent_name' => 'Asia'],
     // 			['name' => 'Kazakhstan', 'parent_name' => 'Asia'],
     // 			['name' => 'Korea Selatan', 'parent_name' => 'Asia'],
     // 			['name' => 'Korea Utara', 'parent_name' => 'Asia'],
     // 			['name' => 'Kuwait', 'parent_name' => 'Asia'],
     // 			['name' => 'Kyrgyzstan', 'parent_name' => 'Asia'],
     // 			['name' => 'Laos', 'parent_name' => 'Asia'],
     // 			['name' => 'Lebanon', 'parent_name' => 'Asia'],
     // 			['name' => 'Makao S.A.R. Cina', 'parent_name' => 'Asia'],
     // 			['name' => 'Malaysia', 'parent_name' => 'Asia'],
     // 			['name' => 'Maldives', 'parent_name' => 'Asia'],
     // 			['name' => 'Mongolia', 'parent_name' => 'Asia'],
     // 			['name' => 'Myanmar', 'parent_name' => 'Asia'],
     // 			['name' => 'Nepal', 'parent_name' => 'Asia'],
     // 			['name' => 'Oman', 'parent_name' => 'Asia'],
     // 			['name' => 'Otoritas Palestina', 'parent_name' => 'Asia'],
     // 			['name' => 'Pakistan', 'parent_name' => 'Asia'],
     // 			['name' => 'Qatar', 'parent_name' => 'Asia'],
     // 			['name' => 'Singapura', 'parent_name' => 'Asia'],
     // 			['name' => 'Siprus', 'parent_name' => 'Asia'],
     // 			['name' => 'Sri Lanka', 'parent_name' => 'Asia'],
     // 			['name' => 'Syria', 'parent_name' => 'Asia'],
     // 			['name' => 'Taiwan', 'parent_name' => 'Asia'],
     // 			['name' => 'Tajikistan', 'parent_name' => 'Asia'],
     // 			['name' => 'Thailand', 'parent_name' => 'Asia'],
     // 			['name' => 'Timor Timur', 'parent_name' => 'Asia'],
     // 			['name' => 'Turkey', 'parent_name' => 'Asia'],
     // 			['name' => 'Turkmenistan', 'parent_name' => 'Asia'],
     // 			['name' => 'Uni Emirat Arab', 'parent_name' => 'Asia'],
     // 			['name' => 'Uzbekistan', 'parent_name' => 'Asia'],
     // 			['name' => 'Vietnam', 'parent_name' => 'Asia'],
     // 			['name' => 'Yaman', 'parent_name' => 'Asia'],
     // 			['name' => 'Yordania', 'parent_name' => 'Asia'],
     // 			['name' => 'Eropa', 'parent_name' => null],
     // 			['name' => 'Albania', 'parent_name' => 'Eropa'],
     // 			['name' => 'Andora', 'parent_name' => 'Eropa'],
     // 			['name' => 'Austria', 'parent_name' => 'Eropa'],
     // 			['name' => 'Belarusia', 'parent_name' => 'Eropa'],
     // 			['name' => 'Belgia', 'parent_name' => 'Eropa'],
     // 			['name' => 'Bosnia dan Herzegovina', 'parent_name' => 'Eropa'],
     // 			['name' => 'Bulgaria', 'parent_name' => 'Eropa'],
     // 			['name' => 'Denmark', 'parent_name' => 'Eropa'],
     // 			['name' => 'Estonia', 'parent_name' => 'Eropa'],
     // 			['name' => 'Finlandia', 'parent_name' => 'Eropa'],
     // 			['name' => 'Gibraltar', 'parent_name' => 'Eropa'],
     // 			['name' => 'Guernsey', 'parent_name' => 'Eropa'],
     // 			['name' => 'Hungaria', 'parent_name' => 'Eropa'],
     // 			['name' => 'Inggris Raya', 'parent_name' => 'Eropa'],
     // 			['name' => 'Irlandia', 'parent_name' => 'Eropa'],
     // 			['name' => 'Islandia', 'parent_name' => 'Eropa'],
     // 			['name' => 'Isle of Man', 'parent_name' => 'Eropa'],
     // 			['name' => 'Itali', 'parent_name' => 'Eropa'],
     // 			['name' => 'Jerman', 'parent_name' => 'Eropa'],
     // 			['name' => 'Jersey', 'parent_name' => 'Eropa'],
     // 			['name' => 'Kepulauan Faroe', 'parent_name' => 'Eropa'],
     // 			['name' => 'Kroasia', 'parent_name' => 'Eropa'],
     // 			['name' => 'Latvia', 'parent_name' => 'Eropa'],
     // 			['name' => 'Liechtenstein', 'parent_name' => 'Eropa'],
     // 			['name' => 'Lithuania', 'parent_name' => 'Eropa'],
     // 			['name' => 'Luxembourg', 'parent_name' => 'Eropa'],
     // 			['name' => 'Macedonia', 'parent_name' => 'Eropa'],
     // 			['name' => 'Malta', 'parent_name' => 'Eropa'],
     // 			['name' => 'Moldova', 'parent_name' => 'Eropa'],
     // 			['name' => 'Monaco', 'parent_name' => 'Eropa'],
     // 			['name' => 'Montenegro', 'parent_name' => 'Eropa'],
     // 			['name' => 'Netherlands', 'parent_name' => 'Eropa'],
     // 			['name' => 'Norwegia', 'parent_name' => 'Eropa'],
     // 			['name' => 'Perancis', 'parent_name' => 'Eropa'],
     // 			['name' => 'Polandia', 'parent_name' => 'Eropa'],
     // 			['name' => 'Portugis', 'parent_name' => 'Eropa'],
     // 			['name' => 'Republik Ceko', 'parent_name' => 'Eropa'],
     // 			['name' => 'Romania', 'parent_name' => 'Eropa'],
     // 			['name' => 'Rusia', 'parent_name' => 'Eropa'],
     // 			['name' => 'San Marino', 'parent_name' => 'Eropa'],
     // 			['name' => 'Serbia', 'parent_name' => 'Eropa'],
     // 			['name' => 'Serbia dan Montenegro', 'parent_name' => 'Eropa'],
     // 			['name' => 'Siprus', 'parent_name' => 'Eropa'],
     // 			['name' => 'Slovakia', 'parent_name' => 'Eropa'],
     // 			['name' => 'Slovenia', 'parent_name' => 'Eropa'],
     // 			['name' => 'Spanyol', 'parent_name' => 'Eropa'],
     // 			['name' => 'Svalbard dan Jan Mayen', 'parent_name' => 'Eropa'],
     // 			['name' => 'Sweden', 'parent_name' => 'Eropa'],
     // 			['name' => 'Swiss', 'parent_name' => 'Eropa'],
     // 			['name' => 'Ukraina', 'parent_name' => 'Eropa'],
     // 			['name' => 'Vatikan', 'parent_name' => 'Eropa'],
     // 			['name' => 'Yunani', 'parent_name' => 'Eropa'],
     // 			['name' => '�Land Islands', 'parent_name' => 'Eropa'],
     // 			['name' => 'Oceania', 'parent_name' => null],
     // 			['name' => 'Antarktika', 'parent_name' => 'Oceania'],
     // 			['name' => 'Australia', 'parent_name' => 'Oceania'],
     // 			['name' => 'British Indian Ocean Territory', 'parent_name' => 'Oceania'],
     // 			['name' => 'Fiji', 'parent_name' => 'Oceania'],
     // 			['name' => 'Georgia Selatan dan Kepulauan Sandwich Selatan', 'parent_name' => 'Oceania'],
     // 			['name' => 'Guam', 'parent_name' => 'Oceania'],
     // 			['name' => 'Kaledonia Baru', 'parent_name' => 'Oceania'],
     // 			['name' => 'Kepualuan Mariana Utara', 'parent_name' => 'Oceania'],
     // 			['name' => 'Kepulauan Bouvet', 'parent_name' => 'Oceania'],
     // 			['name' => 'Kepulauan Cocos', 'parent_name' => 'Oceania'],
     // 			['name' => 'Kepulauan Cook', 'parent_name' => 'Oceania'],
     // 			['name' => 'Kepulauan Marshall', 'parent_name' => 'Oceania'],
     // 			['name' => 'Kepulauan Norfolk', 'parent_name' => 'Oceania'],
     // 			['name' => 'Kepulauan Solomon', 'parent_name' => 'Oceania'],
     // 			['name' => 'Kepulauan minor sekitar Amerika Serikat', 'parent_name' => 'Oceania'],
     // 			['name' => 'Kiribati', 'parent_name' => 'Oceania'],
     // 			['name' => 'Mikronesia', 'parent_name' => 'Oceania'],
     // 			['name' => 'Nauru', 'parent_name' => 'Oceania'],
     // 			['name' => 'Niue', 'parent_name' => 'Oceania'],
     // 			['name' => 'Palau', 'parent_name' => 'Oceania'],
     // 			['name' => 'Papua Nugini', 'parent_name' => 'Oceania'],
     // 			['name' => 'Pitcairn', 'parent_name' => 'Oceania'],
     // 			['name' => 'Polynesia Perancis', 'parent_name' => 'Oceania'],
     // 			['name' => 'Pulau Christmas', 'parent_name' => 'Oceania'],
     // 			['name' => 'Pulau Heard dan Kepulauan McDonald', 'parent_name' => 'Oceania'],
     // 			['name' => 'Samoa', 'parent_name' => 'Oceania'],
     // 			['name' => 'Samoa Amerika', 'parent_name' => 'Oceania'],
     // 			['name' => 'Selandia Baru', 'parent_name' => 'Oceania'],
     // 			['name' => 'Tokelau', 'parent_name' => 'Oceania'],
     // 			['name' => 'Tonga', 'parent_name' => 'Oceania'],
     // 			['name' => 'Tuvalu', 'parent_name' => 'Oceania'],
     // 			['name' => 'Vanuatu', 'parent_name' => 'Oceania'],
     // 			['name' => 'Wallis dan Futuna', 'parent_name' => 'Oceania'],
     // 			['name' => 'Wilayah Prancis Selatan', 'parent_name' => 'Oceania'],
     // 		];
     $destinations = [['name' => 'Eropa', 'parent_name' => null], ['name' => 'Inggris', 'parent_name' => 'Eropa'], ['name' => 'Belanda', 'parent_name' => 'Eropa'], ['name' => 'Perancis', 'parent_name' => 'Eropa'], ['name' => 'Italia', 'parent_name' => 'Eropa'], ['name' => 'Spanyol', 'parent_name' => 'Eropa'], ['name' => 'Portugal', 'parent_name' => 'Eropa'], ['name' => 'Norwegia', 'parent_name' => 'Eropa'], ['name' => 'Swiss', 'parent_name' => 'Eropa'], ['name' => 'Jerman', 'parent_name' => 'Eropa'], ['name' => 'Asia', 'parent_name' => null], ['name' => 'Indonesia', 'parent_name' => 'Asia'], ['name' => 'Bali', 'parent_name' => 'Indonesia'], ['name' => 'Lombok', 'parent_name' => 'Indonesia'], ['name' => 'Thailand', 'parent_name' => 'Asia'], ['name' => 'Vietnam', 'parent_name' => 'Asia'], ['name' => 'China', 'parent_name' => 'Asia'], ['name' => 'Jepang', 'parent_name' => 'Asia'], ['name' => 'Korea Selatan', 'parent_name' => 'Asia'], ['name' => 'Taiwan', 'parent_name' => 'Asia'], ['name' => 'Amerika', 'parent_name' => null], ['name' => 'USA', 'parent_name' => 'Amerika'], ['name' => 'Canada', 'parent_name' => 'Amerika'], ['name' => 'Australia', 'parent_name' => null], ['name' => 'Western Australia', 'parent_name' => 'Australia'], ['name' => 'Victoria', 'parent_name' => 'Australia'], ['name' => 'New South Wales', 'parent_name' => 'Australia'], ['name' => 'Queensland', 'parent_name' => 'Australia'], ['name' => 'Tasmania', 'parent_name' => 'Australia'], ['name' => 'South Australia', 'parent_name' => 'Australia'], ['name' => 'Afrika', 'parent_name' => null], ['name' => 'South Afrika', 'parent_name' => 'Afrika'], ['name' => 'Madagaskar', 'parent_name' => 'Afrika'], ['name' => 'Antartika', 'parent_name' => null]];
     foreach ($destinations as $x) {
         $destination = new Destination();
         $destination->fill(['name' => $x['name'], 'parent_id' => is_null($x['parent_name']) ? null : Destination::NameLike($x['parent_name'])->first()->id]);
         if (!$destination->save()) {
             dd($destination->getErrors());
         }
         $destination->images()->saveMany([new \App\Image(['name' => 'CoverImage', 'path' => 'http://localhost:8000/images/43/' . rand(1, 12) . '.jpg', 'title' => $destination->name, 'description' => $destination->long_name]), new \App\Image(['name' => 'SmallImage', 'path' => 'http://localhost:8000/images/43/' . rand(1, 12) . '.jpg', 'title' => $destination->name, 'description' => $destination->long_name]), new \App\Image(['name' => 'MediumImage', 'path' => 'http://localhost:8000/images/43/' . rand(1, 12) . '.jpg', 'title' => $destination->name, 'description' => $destination->long_name]), new \App\Image(['name' => 'LargeImage', 'path' => 'http://localhost:8000/images/43/' . rand(1, 12) . '.jpg', 'title' => $destination->name, 'description' => $destination->long_name])]);
     }
 }
 public function resorts()
 {
     $idPageResorts = 6;
     $page = Page::resort($this->resortId)->active()->id($idPageResorts)->with(['contents' => function ($query) {
         $query->where('lang_id', '=', $this->langId);
     }])->first();
     if ($page) {
         $page = $page->contents->first();
         $idCancun = 1;
         $idRivieraMaya = 2;
         $idPlayaDelCarmen = 3;
         $destination1 = Destination::active()->id($idCancun)->with(['contents' => function ($query) {
             $query->select('destination_contents.destination_id', 'destination_contents.short_description', 'destination_contents.alt1');
             $query->where('lang_id', '=', $this->langId);
         }])->with(['resorts.contents' => function ($query) {
             $query->select('resort_contents.resort_id', 'resort_contents.short_description', 'resort_contents.short_offer', 'resort_contents.alt1');
             $query->where('lang_id', '=', $this->langId);
         }])->first();
         $destination2 = Destination::active()->id($idRivieraMaya)->with(['contents' => function ($query) {
             $query->select('destination_contents.destination_id', 'destination_contents.short_description', 'destination_contents.alt1');
             $query->where('lang_id', '=', $this->langId);
         }])->with(['resorts.contents' => function ($query) {
             $query->select('resort_contents.resort_id', 'resort_contents.short_description', 'resort_contents.short_offer', 'resort_contents.alt1');
             $query->where('lang_id', '=', $this->langId);
         }])->first();
         $destination3 = Destination::active()->id($idPlayaDelCarmen)->with(['contents' => function ($query) {
             $query->select('destination_contents.destination_id', 'destination_contents.short_description', 'destination_contents.alt1');
             $query->where('lang_id', '=', $this->langId);
         }])->with(['resorts.contents' => function ($query) {
             $query->select('resort_contents.resort_id', 'resort_contents.short_description', 'resort_contents.short_offer', 'resort_contents.alt1');
             $query->where('lang_id', '=', $this->langId);
         }])->first();
         //return dd($destination3->toArray());
         return View('pages.resorts', compact('page', 'destination1', 'destination2', 'destination3'));
     }
 }
Esempio n. 20
-1
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     with(new \App\Tag(['tag' => 'adventure']))->save();
     // DB::enableQueryLog();
     //
     for ($i = 1; $i <= 200; $i++) {
         $destination = \App\Destination::whereNotNull('parent_id')->orderByRaw("RAND()")->first();
         $destination_id = $destination->id;
         // TOUR
         $duration = rand(3, 12);
         $tour = new Tour();
         $tour->fill(['travel_agent_id' => rand(1, 6), 'name' => $duration . 'D/' . ($duration - 1) . 'N ' . $destination->name, 'ittinary' => 'Lorem ipsum Incididunt ut velit voluptate ullamco occaecat ut laboris ad nulla mollit eu Ut sed do dolor sit aliqua amet dolore dolore laboris occaecat ad nulla mollit minim officia voluptate ex et proident dolore cillum dolore do nostrud et exercitation amet commodo magna ex amet sit minim cillum Duis proident amet consequat amet proident fugiat culpa velit qui eu consequat irure nulla consequat sit laborum est deserunt dolore enim id aliquip nisi pariatur pariatur irure tempor in fugiat consectetur ut deserunt Duis tempor dolor dolore laboris ullamco ullamco amet Duis nostrud amet consequat consequat ea non nisi elit cupidatat esse dolor esse exercitation dolor incididunt voluptate dolore nostrud dolor reprehenderit in cupidatat tempor consectetur cupidatat sed dolor amet deserunt cillum occaecat nulla Duis enim consequat enim tempor adipisicing nisi cillum do sed cupidatat reprehenderit Ut.', 'summary' => 'Lorem ipsum Pariatur amet irure labore aute Duis ea irure proident adipisicing adipisicing velit elit in non incididunt ea fugiat exercitation ex enim dolore.', 'duration_day' => $duration, 'duration_night' => $duration - 1, 'published_at' => \Carbon\Carbon::now(), 'slug' => str_slug($duration . 'D/' . ($duration - 1) . 'N ' . $destination->name . ' ' . $i), 'tag_ids' => 1]);
         if (!$tour->save()) {
             dd($tour->getErrors());
         }
         $is_fit = rand(0, 100) < 20;
         // TOUR DESTINATION
         $tour->destinations()->sync([$destination_id]);
         // PLACES
         $places = \App\Place::whereIn('destination_id', $tour->destinations->lists('id'))->limit($tour->duration_day)->orderByRaw('rand()')->get();
         // $queries = DB::getQueryLog();
         // dd(end($queries));
         if ($places->count()) {
             $tour->places()->sync($places->lists('id')->toArray());
         }
         // SCHEDULE
         if (!$is_fit) {
             $departure = \Carbon\Carbon::now()->startOfMonth()->addDay(rand(0, 240));
             $original_price = $duration * rand(1, 10) * 300000;
             $tour->schedules()->saveMany([new \App\TourSchedule(['departure' => $departure, 'departure_until' => \Carbon\Carbon::parse($departure)->addDay(rand(30, 150)), 'currency' => 'IDR', 'original_price' => $original_price, 'discounted_price' => $original_price * (rand(0, 100) <= 20 ? rand(80, 100) / 100 : 1), 'views' => 0])]);
         } else {
             for ($j = 1; $j <= rand(3, 5); $j++) {
                 $departure = \Carbon\Carbon::now()->startOfMonth()->addDay(rand(0, 240));
                 $original_price = $duration * rand(1, 10) * 300000;
                 $tour->schedules()->saveMany([new \App\TourSchedule(['departure' => $departure, 'departure_until' => null, 'currency' => 'IDR', 'original_price' => $original_price, 'discounted_price' => $original_price * (rand(0, 100) <= 20 ? rand(80, 100) / 100 : 1), 'views' => 0])]);
             }
         }
         // OPTIONS
         $tour->options()->sync([1 => ['description' => rand(1, 5)], 3 => ['description' => 'Singapore Airlines'], 5 => ['description' => ''], 6 => ['description' => '']]);
     }
 }