Exemple #1
0
 private function findAlbums()
 {
     $result = [];
     $query = Album::find()->status(Album::STATUS_ON)->sort();
     if ($this->_albumsOptions['where']) {
         $query->andWhere($this->_albumsOptions['where']);
     }
     if ($this->_albumsOptions['photos'] > 0) {
         $query->with('photos');
     }
     $this->_adp = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $this->_albumsOptions['pageSize']]]);
     foreach ($this->_adp->models as $album) {
         $albumObject = $this->parseAlbum($album);
         if ($this->_albumsOptions['photos'] > 0) {
             $albumObject->photos = $this->parsePhotos($album->photos, $this->_albumsOptions['photos']);
         }
         $result[] = $albumObject;
     }
     return $result;
 }
Exemple #2
0
 public function getPhotos()
 {
     return $this->hasMany(Photo::className(), ['item_id' => 'album_id'])->where(['model' => Album::className()])->sort();
 }
Exemple #3
0
 public function actionDelete($id)
 {
     if ($model = Album::findOne($id)) {
         $model->delete();
     } else {
         $this->error = Yii::t('easyii', 'Not found');
     }
     return $this->formatResponse(Yii::t('easyii/gallery', 'Album deleted'));
 }
 public function down()
 {
     $this->dropTable(models\Admin::tableName());
     $this->dropTable(models\LoginForm::tableName());
     $this->dropTable(models\Module::tableName());
     $this->dropTable(models\Photo::tableName());
     $this->dropTable(models\Setting::tableName());
     $this->dropTable(Carousel::tableName());
     $this->dropTable(Category::tableName());
     $this->dropTable(Item::tableName());
     $this->dropTable(Feedback::tableName());
     $this->dropTable(File::tableName());
     $this->dropTable(Album::tableName());
     $this->dropTable(Guestbook::tableName());
     $this->dropTable(News::tableName());
     $this->dropTable(Page::tableName());
     $this->dropTable(Subscriber::tableName());
     $this->dropTable(History::tableName());
     $this->dropTable(Text::tableName());
 }