コード例 #1
0
ファイル: CorporateSearch.php プロジェクト: allhaze/renault
 /**
  * Creates data provider instance with search query applied
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Corporate::find();
     if (!\Yii::$app->user->can('administrator')) {
         $query->forDomain();
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'domain_id' => $this->domain_id]);
     $query->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'secondname', $this->secondname])->andFilterWhere(['like', 'lastname', $this->lastname])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'phone', $this->phone]);
     return $dataProvider;
 }
コード例 #2
0
 /**
  * Finds the Corporate model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Corporate the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Corporate::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested Corporate does not exist.');
     }
 }