Exemple #1
0
 /**
  * @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;
 }
Exemple #2
0
 /**
  *
  * 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;
 }