/**
  * Finds the Authitemchild model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $parent
  * @param string $child
  * @return Authitemchild the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($parent, $child)
 {
     if (($model = Authitemchild::findOne(['parent' => $parent, 'child' => $child])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#2
0
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $Authitemchild = new Authitemchild();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(Proc::GetPreviousURLBreadcrumbsFromSession());
     } else {
         $Authitemchild->load(Yii::$app->request->get(), 'Authitemchild');
         $Authitemchild->parent = $model->primaryKey;
         if ($Authitemchild->validate()) {
             $Authitemchild->save(false);
         }
         $searchModel = new AuthitemchildSearch();
         $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
         return $this->render('update', ['model' => $model, 'Authitemchild' => $Authitemchild, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
     }
 }
示例#3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Authitemchild::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $query->joinWith(['children']);
     $this->load($params);
     $this->parent = $params['id'];
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['like', 'parent', $this->parent])->andFilterWhere(['like', 'child', $this->child]);
     $query->andFilterWhere(['LIKE', 'children.description', $this->getAttribute('children.description')]);
     $query->andFilterWhere(['LIKE', 'children.type', $this->getAttribute('children.type')]);
     $query->andFilterWhere(['LIKE', 'children.name', $this->getAttribute('children.name')]);
     Proc::AssignRelatedAttributes($dataProvider, ['children.description', 'children.type', 'children.name']);
     return $dataProvider;
 }
示例#4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAuthitemchildrenchild()
 {
     return $this->hasMany(Authitemchild::className(), ['child' => 'name'])->from(['authitemchildrenchild' => Authitemchild::tableName()]);
 }