/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = UsersRequest::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(['request_id' => $this->request_id, 'user_id' => $this->user_id]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = UsersRequest::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $query->joinWith(['request', 'user']); $dataProvider->sort->attributes['user_name'] = ['asc' => ['user.first_name' => SORT_ASC], 'desc' => ['user.first_name' => SORT_DESC]]; $dataProvider->sort->attributes['request_Subject'] = ['asc' => ['request.subject' => SORT_ASC], 'desc' => ['request_subject' => SORT_DESC]]; $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(['request_id' => $this->request_id, 'user_id' => $this->user_id])->andFilterWhere(['like', 'user.first_name', $this->user_name])->andFilterWhere(['like', 'resquest.subject', $this->request_Subject]); return $dataProvider; }
/** * Unassign a responsible for the request. * For ajax request will return json object * and for non-ajax request if deletion is successful, the browser will be redirected to the 'index' page. * @param string $id * @return mixed * @throws NotFoundHttpException */ public function actionUnasign($r_id, $u_id) { $model = UsersRequest::find()->where(['user_id' => $u_id, 'request_id' => $r_id])->one(); $model->delete(); return $this->redirect('advanced?id=' . $r_id); }