/** * Creates a new AuthItem model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Route(); if ($model->load(Yii::$app->getRequest()->post())) { if ($model->validate()) { $routes = preg_split('/\\s*,\\s*/', trim($model->route), -1, PREG_SPLIT_NO_EMPTY); $this->saveNew($routes); MenuHelper::invalidate(); $this->redirect(['index']); } } return $this->render('create', ['model' => $model]); }
/** * Finds the Route model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Route the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Route::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Route::find()->where('active!=3'); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['IDroute' => $this->IDroute, 'IDstationFrom' => $this->IDstationFrom, 'IDstationTo' => $this->IDstationTo, 'active' => $this->active]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getIDroute() { return $this->hasOne(Route::className(), ['IDroute' => 'IDroute']); }
/** * @return \yii\db\ActiveQuery */ public function getRoutes() { return $this->hasMany(Route::className(), ['IDstationTo' => 'IDstation']); }