예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     /*params group */
     $group = $params['ChatSearch']['GROUP'];
     // componen user
     $profile = Yii::$app->getUserOpt->profile_user()->emp;
     $emp_id = $profile->EMP_ID;
     if ($params['chat'] == 'group') {
         $query = Chat::find()->where(['GROUP_ID' => $group]);
     } else {
         $query = Chat::find()->where(['CREATED_BY' => $emp_id])->orwhere(['GROUP_ID' => $emp_id]);
     }
     $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(['ID' => $this->ID, 'MESSAGE_STS' => $this->MESSAGE_STS, 'MESSAGE_SHOW' => $this->MESSAGE_SHOW, 'GROUP_ID' => $this->GROUP_ID, 'UPDATED_TIME' => $this->UPDATED_TIME]);
     $query->andFilterWhere(['like', 'MESSAGE', $this->MESSAGE])->andFilterWhere(['like', 'MESSAGE_ATTACH', $this->MESSAGE_ATTACH])->andFilterWhere(['like', 'GROUP_ID', $this->GROUP_ID]);
     // ->andFilterWhere(['like', 'sc0003a.CREATED_BY', $this->CREATED_BY]);
     return $dataProvider;
 }
예제 #2
0
 /**
  * Finds the Chat model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Chat the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Chat::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }