예제 #1
0
 public function getIndex()
 {
     // ------------------------------------------------------------------------------------------------------------
     // FILTERS
     // ------------------------------------------------------------------------------------------------------------
     $filters['name'] = Input::get('filter_place_name');
     $filters['destination'] = Input::get('filter_destination_id');
     // ------------------------------------------------------------------------------------------------------------
     // QUERY PLACE
     // ------------------------------------------------------------------------------------------------------------
     $places = $this->model->NameLike('*' . str_replace(' ', '*', $filters['name']) . '*')->InDestinationByIds(\App\Destination::withSubtreeById($filters['destination'])->get()->lists('id')->toArray())->latest()->paginate(30);
     // ------------------------------------------------------------------------------------------------------------
     // QUERY DESTINATION
     // ------------------------------------------------------------------------------------------------------------
     $destinations = \App\Destination::orderBy(\App\Destination::getPathField());
     if ($filters['destination']) {
         $filtered_destination = \App\Destination::find($filters['destination']);
     }
     // ------------------------------------------------------------------------------------------------------------
     // SHOW DISPLAY
     // ------------------------------------------------------------------------------------------------------------
     $this->layout->page = view($this->page_base_dir . 'index')->with('route_name', $this->route_name)->with('view_name', $this->view_name);
     $this->layout->page->filters = $filters;
     $this->layout->page->places = $places;
     $this->layout->page->required_images = $this->required_images;
     $this->layout->page->destinations = $destinations;
     $this->layout->page->filtered_destination = $filtered_destination;
     return $this->layout;
 }