/**
  * 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;
 }
Example #2
0
 /**
  * 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;
 }
Example #3
0
 /**
  * Finds the UsersRequest model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $request_id
  * @param string $user_id
  * @return UsersRequest the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($request_id, $user_id)
 {
     if (($model = UsersRequest::findOne(['request_id' => $request_id, 'user_id' => $user_id])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUsersRequests()
 {
     return $this->hasMany(UsersRequest::className(), ['request_id' => 'id']);
 }
 /**
  * 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);
 }