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;
 }
Beispiel #2
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());
         }
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Destination::find($id)->delete();
     return redirect('/admin/destination');
 }
 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'];
 }