[ 'class' => VerbFilter::className(), 'actions' => [ ], ], 'access' => [ 'class' => AccessControl::className(), 'rules' => [ [ 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) { return User::getCurrentStatus() == USER::STATUS_ADMIN; } ] ], ], ]; } /** * Liste les tranches de prix. * * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider([ 'query' => ProducerPriceRange::find()->orderBy('range_begin ASC') ]); return $this->render('index', [ 'dataProviderProducerPriceRange' => $dataProvider, ]); } /** * Crée une tranche de prix. * * @return mixed */ public function actionCreate() { $model = new ProducerPriceRange(); if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->getSession()->setFlash('success', 'Tranche de prix créée.'); return $this->redirect(['index']); } else { return $this->render('create', [ 'model' => $model, ]); } } /** * Édition d'une tranche de prix. * * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->getSession()->setFlash('success', 'Tranche de prix éditée.'); return $this->redirect(['index']); } else { return $this->render('update', [ 'model' => $model, ]); } } /** * Supprime une tranche de prix. * * @param integer $id */ public function actionDelete($id) { $producerPriceRange = ProducerPriceRange::searchOne([ 'id' => $id ]) ; $producerPriceRange->delete(); Yii::$app->getSession()->setFlash('success', 'Tranche de prix supprimée.'); return $this->redirect(['producer-price-range-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 ProducerPriceRange the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = ProducerPriceRange::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } } }