コード例 #1
0
ファイル: Album.php プロジェクト: graker/photoalbums
 /**
  *
  * 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;
 }
コード例 #2
0
ファイル: Upload.php プロジェクト: graker/photoalbums
 /**
  * @return array of [album id => album title] to use in select list
  */
 protected function getAlbumsList()
 {
     $albums = AlbumModel::orderBy('created_at', 'desc')->get();
     $options = [];
     foreach ($albums as $album) {
         $options[$album->id] = $album->title;
     }
     return $options;
 }
コード例 #3
0
ファイル: AlbumList.php プロジェクト: graker/photoalbums
 /**
  *
  * Returns array of site's albums to be used in component
  * Albums are sorted by created date desc, each one loaded with one latest photo
  * Empty albums won't be displayed
  *
  * @return array
  */
 protected function loadAlbums()
 {
     $albums = AlbumModel::orderBy('created_at', 'desc')->has('photos')->with(['latestPhoto' => function ($query) {
         $query->with('image');
     }])->with('photosCount')->paginate($this->property('albumsOnPage'), $this->currentPage);
     return $albums;
 }