コード例 #1
0
ファイル: PersonSearch.php プロジェクト: azrapiric/vicevi
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Person::find();
     $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(['id' => $this->id, 'role' => $this->role, 'active' => $this->active]);
     $query->andFilterWhere(['like', 'nick', $this->nick])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'password', $this->password]);
     return $dataProvider;
 }
コード例 #2
0
ファイル: Joke.php プロジェクト: azrapiric/vicevi
 public function getPerson()
 {
     return $this->hasOne(Person::className(), ['id' => 'person_id']);
 }
コード例 #3
0
ファイル: PersonController.php プロジェクト: azrapiric/vicevi
 /**
  * Finds the Person model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Person the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Person::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }