/**
  * Set as main image
  * @param string $id
  * @return mixed
  */
 public function actionMain()
 {
     // Reset previous main image
     Image::updateAll(['isMain' => 0], ['isMain' => 1, 'itemId' => Yii::$app->session->get('gallery.gallery-id'), 'modelName' => StringHelper::basename(Gallery::className())]);
     // Set new main image
     $model = $this->findModel(Yii::$app->request->post('id'));
     $model->isMain = 1;
     $model->active = 1;
     return $model->save();
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getGallery()
 {
     return $this->hasOne(Gallery::className(), ['id' => 'gallery_id']);
 }