Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Complaint::find();
     $query->joinWith(array('status', 'complainant'));
     $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(['Complaint.id' => $this->id, 'Complaint.registration_time' => $this->registration_time]);
     $query->andFilterWhere(array('like', 'Complainant.cnic', $this->cnic));
     $query->andFilterWhere(array('like', 'Complainant.name', $this->name));
     $query->andFilterWhere(array('like', 'ComplaintStatus.value', $this->status));
     return $dataProvider;
 }
Ejemplo n.º 2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     try {
         $complaint = Complaint::find($id);
         $complaint->delete();
     } catch (Exception $e) {
         return redirect()->back()->withMessage('Error deleting Complaint, Possibly it is already Deleted')->withStatus('error');
     }
     return redirect()->route('complaints.index', compact('complaint'))->withMessage('Complaints Updated')->withStatus('success');
 }
Ejemplo n.º 3
0
 /**
  * Finds the Complaint model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Complaint the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Complaint::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getComplaints()
 {
     return $this->hasMany(Complaint::className(), ['status_id' => 'id']);
 }