[ 'class' => VerbFilter::className(), 'actions' => [ 'delete' => ['post'], ], ], 'access' => [ 'class' => AccessControl::className(), 'rules' => [ [ 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) { return Yii::$app->user->identity->status == USER::STATUS_ADMIN || Yii::$app->user->identity->status == USER::STATUS_BOULANGER; } ] ], ], ]; } public function actionUpdate() { $request = Yii::$app->request ; $model = $this->findModel(Yii::$app->user->identity->id_etablissement); $logo_filename_old = $model->logo ; $photo_filename_old = $model->photo ; if ($model->load(Yii::$app->request->post()) && $model->save()) { Upload::uploadFile($model, 'logo', $logo_filename_old) ; Upload::uploadFile($model, 'photo', $photo_filename_old) ; $delete_logo = $request->post('delete_logo',0) ; if($delete_logo) { $model->logo = '' ; $model->save() ; } $delete_photo = $request->post('delete_photo',0) ; if($delete_photo) { $model->photo = '' ; $model->save() ; } return $this->redirect(['update', 'id' => $model->id, 'edit_ok' => true]); } else { return $this->render('update', [ 'model' => $model, ]); } } protected function findModel($id) { if (($model = Etablissement::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } } }