public function actionDeleteGalleryImage()
 {
     if (Yii::$app->request->isAjax and $id = Yii::$app->request->post('id')) {
         if ($model = Image::findOne($id)) {
             $model->delete();
             unlink('images/products/galleries/' . $model->name);
             return true;
         }
         return false;
     } else {
         return $this->redirect(Yii::$app->request->referrer);
     }
     // if ($id = Yii::$app->request->post('image_id')) {
     //     if ($model = Image::findOne($id)) {
     //         $model->delete();
     //         unlink('images/products/galleries/'. $model->name);
     //         return $this->redirect(Yii::$app->request->referrer);
     //     }
     // }
 }
 /**
  * Finds the Image model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Image the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Image::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }