/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Scans::find()->where(['scans.user_id' => Yii::$app->user->id]); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->joinWith('usersUser'); $query->joinWith('customersCustomer'); $query->andFilterWhere(['scan_id' => $this->scan_id]); $query->andFilterWhere(['like', 'scan_name', $this->scan_name]); $query->andFilterWhere(['like', 'path', $this->path]); $query->andFilterWhere(['like', 'user.username', $this->user_id]); $query->andFilterWhere(['like', 'customers.customer_name', $this->customer_id]); return $dataProvider; }
/** * Finds the Scans model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Scans the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Scans::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('Запрашиваемая страница недоступна.'); } }