Exemple #1
0
 /**
  *
  * Loads album model with it's photos
  *
  * @return AlbumModel
  */
 protected function loadAlbum()
 {
     $slug = $this->property('slug');
     $album = AlbumModel::where('slug', $slug)->with(['photos' => function ($query) {
         $query->orderBy('created_at', 'desc');
         $query->with('image');
         $query->paginate($this->property('photosOnPage'), $this->currentPage);
     }])->first();
     if ($album) {
         //prepare photo urls and thumbs
         foreach ($album->photos as $photo) {
             $photo->url = $photo->setUrl($this->property('photoPage'), $this->controller);
             $photo->thumb = $photo->image->getThumb($this->property('thumbWidth'), $this->property('thumbHeight'), ['mode' => $this->property('thumbMode')]);
         }
         //setup page numbers
         $this->lastPage = ceil($album->photosCount / $this->property('photosOnPage'));
     }
     return $album;
 }