コード例 #1
0
ファイル: MenuSearch.php プロジェクト: radiata-cms/radiata
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Menu::find();
     $query->language();
     $query->orderBy(['position' => SORT_ASC]);
     $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;
     }
     $query->andFilterWhere(['status' => $this->status]);
     $query->andWhere([Menu::tableName() . '.parent_id' => $this->parent_id]);
     $query->andFilterWhere(['like', 'title', $this->title]);
     return $dataProvider;
 }
コード例 #2
0
 /**
  * Finds the Menu model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Menu the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     $model = Menu::find()->where(['id' => $id])->with('translations')->one();
     if ($model !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }