コード例 #1
0
ファイル: Menu.php プロジェクト: cinghie/yii2-menu
 /**
  * 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;
 }
コード例 #2
0
ファイル: ItemsSearch.php プロジェクト: cinghie/yii2-menu
 /**
  * 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;
 }
コード例 #3
0
ファイル: ItemsController.php プロジェクト: cinghie/yii2-menu
 /**
  * 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.');
     }
 }
コード例 #4
0
ファイル: Items.php プロジェクト: cinghie/yii2-menu
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getChilds()
 {
     return $this->hasMany(Items::className(), ['parentid' => 'id']);
 }