Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function searchForAjax($params)
 {
     $query = CascadeData::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $limit = isset($params['limit']) ? $params['limit'] : 10;
     $this->name = isset($params['q']) ? $params['q'] : '';
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['like', 'name', $this->name]);
     $query->limit($limit);
     return $dataProvider;
 }
 /**
  * Finds the CascadeData model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return CascadeData the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = CascadeData::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #3
0
 /**
  * 自我表关联
  */
 public function getMySelf()
 {
     return $this->hasOne(CascadeData::className(), ['id' => 'parent_id']);
 }