/** * * AJAX callback * Returns array of all markers in the system * * @return string json */ public function onMarkersLoad() { $markers = Marker::all(); return $markers->toJson(); }
/** * * Returns collection of markers ordered by creation date backwards * * @return Collection */ public function loadMarkers() { $markers = Marker::orderBy('created_at', 'desc')->with('image')->with('posts')->with(['albums' => function ($query) { $query->with('latestPhoto'); }])->paginate($this->property('markersOnPage'), $this->currentPage); return $this->prepareMarkers($markers); }
/** * * Renders info box in response to marker's click * * @return string */ public function onMarkerClicked() { $id = Request::input('marker_id'); $model = Marker::where('id', $id)->with('posts')->with(['albums' => function ($query) { $query->with('latestPhoto'); }])->with('image')->first(); $model->thumb = $model->getMarkerThumb(['width' => $this->property('thumbWidth'), 'height' => $this->property('thumbHeight'), 'mode' => $this->property('thumbMode')]); //setup urls for posts and albums if ($model->posts) { foreach ($model->posts as $post) { $post->setUrl($this->property('postPage'), $this->controller); } } if ($model->albums) { foreach ($model->albums as $album) { $album->setUrl($this->property('albumPage'), $this->controller); } } $model->singleUrl = $this->getSingleUrl($model); return $this->renderPartial('::popup', ['marker' => $model]); }