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; }
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; }
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; }
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; }
public function index($destination_slug = null, $tag = null, $page = 1) { // ------------------------------------------------------------------------ // REDIRECT IF THERE'S REQUEST QUERY // ------------------------------------------------------------------------ if (Input::has('destination') || Input::has('tag')) { return redirect()->route('web.places', ['destination' => Input::get('destination'), 'kategori' => implode(',', Input::get('tag')), 'page' => null] + Input::only('nama')); } // ------------------------------------------------------------------------ // HANDLE FILTERS // ------------------------------------------------------------------------ // Destination List $destination_list = Cache::remember('all_destination_list', 30, function () { return \App\Destination::orderBy('path')->get(); }); $destination_list = ['semua' => "Semua"] + $destination_list->lists('long_name', 'path_slug')->toArray(); $filters['destination'] = $destination_slug; if (str_is('semua', $filters['destination']) || is_null($filters['destination'])) { $filters['destination'] = null; } else { $destination = \App\Destination::findPath(str_replace(',', Destination::getDelimiter(), $filters['destination'] . '*'))->first(); if (!$destination) { return App::abort(404); } } // TAG LIST $tag_list = ['kuliner' => 'food', 'belanja' => 'bag', 'budaya' => 'culture', 'pemandangan' => 'nature', 'hiburan' => 'entertain', 'kesehatan' => 'briefcase-plus']; asort($tag_list); $filters['tags'] = array_filter(explode(',', $tag)); if (!empty($filters['tags'])) { foreach ($filters['tags'] as $x) { if (!array_key_exists($x, $tag_list)) { App::abort(404); } } } // NAMA $filters['nama'] = Input::get('nama'); // ------------------------------------------------------------------------ // PREPARE QUERY // ------------------------------------------------------------------------ // pagination $page = max(1, $page * 1); $per_page = 10; $skip = ($page - 1) * $per_page; // ------------------------------------------------------------------------ // EXECUTE QUERY // ------------------------------------------------------------------------ $places = Cache::remember('all_place_in_' . serialize($filters) . '_skip' . $skip . '_take_' . $per_page, 30, function () use($skip, $per_page, $filters) { $places = Place::inDestinationByPathAndChildren(str_replace(',', Destination::getDelimiter(), $filters['destination'] . '*'))->published()->LongNameLike('*' . $filters['nama'] . '*')->InTagByTag($filters['tags'])->skip($skip)->take($per_page)->latest('published_at')->get(); $places->load('destination', 'images', 'upcoming_tours', 'upcoming_tours.schedules'); return $places; }); $place_count = Cache::remember('count_all_place_in_' . serialize($filters), 30, function () use($skip, $per_page, $filters) { $places = Place::inDestinationByPathAndChildren(str_replace(',', Destination::getDelimiter(), $filters['destination'] . '*'))->InTagByTag(explode(',', $filters['tags']))->published()->LongNameLike('*' . $filters['nama'] . '*')->count(); return $places; }); // ------------------------------------------------------------------------------------------------------------ // SHOW DISPLAY // ------------------------------------------------------------------------------------------------------------ $this->layout->page = view($this->page_base_dir . 'places'); $this->layout->page->destination = $destination; $this->layout->page->destination_list = $destination_list; $this->layout->page->tag_list = $tag_list; $this->layout->page->filters = $filters; $this->layout->page->places = $places; $this->layout->page->option_list = $this->option_list; $this->layout->page->current_page = $page; $this->layout->page->per_page = $per_page; $this->layout->page->start_pagination = max(1, $page - 3); $this->layout->page->last_pagination = min(ceil($place_count / $per_page), $page + 3); $this->layout->title = "Tujuan Wisata "; if ($destination->id) { $this->layout->title .= "di " . $destination->name; } $this->layout->title .= "- Capcus.id"; $this->layout->og['title'] = $this->layout->title; $this->layout->og['type'] = 'website'; $this->layout->og['image'] = $places->count() ? $places->first()->images->where('name', 'LargeImage')->path : asset('images/logo-black.png'); $this->layout->og['image:type'] = pathinfo('images/' . $this->layout->og['image'], PATHINFO_EXTENSION); $this->layout->og['image:width'] = 275; $this->layout->og['image:height'] = 121; return $this->layout; }