[ 'class' => VerbFilter::class, 'actions' => [ 'delete' => ['post'], ], ], 'access' => [ 'class' => AccessControl::class, 'rules' => [ [ 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) { return $this->isUserCurrentAdmin(); } ] ], ], ]; } public function actionIndex() { $dataProviderTaxRate = new ActiveDataProvider([ 'query' => TaxRate::find() ]); return $this->render('index', [ 'dataProviderTaxRate' => $dataProviderTaxRate, ]); } public function actionCreate() { $model = $this->getTaxRateManager()->createTaxRate(); if ($model->load(\Yii::$app->request->post()) && $model->save()) { $this->setFlash('success', 'Taxe créée.'); return $this->redirect(['index']); } else { return $this->render('create', [ 'model' => $model, ]); } } public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(\Yii::$app->request->post()) && $model->save()) { $this->setFlash('success', 'Taxe éditée.'); return $this->redirect(['index']); } else { return $this->render('update', [ 'model' => $model, ]); } } public function actionDelete(int $id) { $taxeRate = TaxRate::searchOne([ 'id' => $id ]); $taxeRate->delete(); $this->setFlash('success', 'Taxe supprimé'); return $this->redirect(['tax-rate-admin/index']); } protected function findModel($id) { if (($model = TaxRate::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } } }