Exemplo n.º 1
0
 /**
  * Return an array with the user roles
  * @return array
  */
 public function getRoles()
 {
     $sql = 'SELECT name FROM {{%auth_item}} WHERE type = 1 ORDER BY name ASC';
     $roles = Items::findBySql($sql)->asArray()->all();
     $array = ['public' => 'Public', 'only guest' => 'Only Guest'];
     foreach ($roles as $role) {
         $array[$role['name']] = ucwords($role['name']);
     }
     return $array;
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Items::find()->where('id != :id', ['id' => 1]);
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'menutypeid' => $this->menutypeid, 'parentid' => $this->parentid, 'state' => $this->state]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'link', $this->link])->andFilterWhere(['like', 'params', $this->params])->andFilterWhere(['like', 'linkOptions', $this->linkOptions])->andFilterWhere(['like', 'access', $this->access])->andFilterWhere(['like', 'language', $this->language]);
     return $dataProvider;
 }
Exemplo n.º 3
0
 /**
  * Finds the Items model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Items the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Items::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getChilds()
 {
     return $this->hasMany(Items::className(), ['parentid' => 'id']);
 }