[ 'class' => VerbFilter::className(), 'actions' => [ 'delete' => ['post'], ], ], 'access' => [ 'class' => AccessControl::className(), 'rules' => [ [ 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) { return User::getCurrentStatus() == USER::STATUS_ADMIN; } ] ], ], ]; } /** * Liste les taxes. * * @return mixed */ public function actionIndex() { $dataProviderTaxRate = new ActiveDataProvider([ 'query' => TaxRate::find() ]); return $this->render('index', [ 'dataProviderTaxRate' => $dataProviderTaxRate, ]); } /** * Crée une taxe. * * @return mixed */ public function actionCreate() { $model = new TaxRate(); if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->getSession()->setFlash('success', 'Taxe créé.'); return $this->redirect(['index']); } else { return $this->render('create', [ 'model' => $model, ]); } } /** * Édition d'une taxe. * * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->getSession()->setFlash('success', 'Taxe édité.'); return $this->redirect(['index']); } else { return $this->render('update', [ 'model' => $model, ]); } } /** * Supprime une commande récurrente. * * @param integer $id */ public function actionDelete($id) { $taxeRate = TaxRate::searchOne([ 'id' => $id ]) ; $taxeRate->delete(); Yii::$app->getSession()->setFlash('success', 'Taxe supprimé'); return $this->redirect(['tax-rate-admin/index']); } /** * Finds the Developpement model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Developpement the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = TaxRate::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } } }