Exemplo n.º 1
0
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  *
  * Typical usecase:
  * - Initialize the model fields with values from filter form.
  * - Execute this method to get CActiveDataProvider instance which will filter
  * models according to data in model fields.
  * - Pass data provider to CGridView, CListView or any similar widget.
  *
  * @return CActiveDataProvider the data provider that can return the models
  * based on the search/filter conditions.
  */
 public function search($params)
 {
     $query = DatabasesPerm::find();
     $dataProvider = new \yii\data\ActiveDataProvider(['query' => $query, "sort" => ['defaultOrder' => []]]);
     //exit;
     $this->load($params);
     if (!$this->validate()) {
         var_dump($this->getErrors());
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'database_id' => $this->database_id, 'level_id' => $this->level_id]);
     //$sort->defaultOrder = 'issue_date DESC';
     return $dataProvider;
 }
Exemplo n.º 2
0
 public function actionPermissions($id)
 {
     //$model=  DatabasesPerm::findOne($id);
     $model = new DatabasesPerm();
     $model->scenario = 'search';
     //$model->unsetAttributes();  // clear any default values
     $model->database_id = $id;
     $user = new DatabasesPerm();
     $user->database_id = $id;
     if ($user->load(Yii::$app->request->post())) {
         $user->save();
         //if($model->save())
         //    $this->redirect(array('index'));
     }
     return $this->render('permissions', array('model' => $model, 'user' => $user));
 }
Exemplo n.º 3
0
 /**
  * @return string the associated database table name
  */
 public function getLevel()
 {
     $level = DatabasesPerm::findOne(array($this->id, Yii::$app->user->id));
     return $level;
 }