Exemplo n.º 1
0
 public function reorderGalleryImages($idsSorted)
 {
     if (count($idsSorted) > 1) {
         foreach ($idsSorted as $newPosition => $id) {
             $galleryImage = GalleryImage::findOne($id);
             $galleryImage->sort_order = $newPosition;
             $galleryImage->save();
         }
     }
 }
Exemplo n.º 2
0
 public function actionDeleteImage($id)
 {
     if (Yii::$app->request->isAjax) {
         try {
             $galleryImage = GalleryImage::findOne($id);
             $galleryImage->delete();
             $message = Yii::t('app', 'Image deleted Successfully');
         } catch (\Exception $e) {
             $message = isset($e->errorInfo[2]) ? $e->errorInfo[2] : $e->getMessage();
         }
         return $message;
     }
 }
Exemplo n.º 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getGalleryImages()
 {
     return $this->hasMany(\common\models\GalleryImage::className(), ['gallery_id' => 'id']);
 }