/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { /* componen */ $profile_id = Yii::$app->getUserOpt->profile_user()->emp->EMP_ID; $sort = Chatroom::find()->where(['GROUP_ID' => $profile_id])->one(); $query = Chatroom::find()->where(['SORT' => $sort, 'PARENT' => 0]); $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, 'PARENT' => $this->PARENT, 'SORT' => $this->SORT]); $query->andFilterWhere(['like', 'GROUP_ID', $this->GROUP_ID])->andFilterWhere(['like', 'GROUP_NM', $this->GROUP_NM]); $query->orderby(['SORT' => SORT_ASC]); return $dataProvider; }
* @author : wawan */ if (count($params) == 0) { $useavatar = Yii::$app->getUserOpt->profile_user()->emp; if ($useavatar->IMG_BASE64) { $gambaravatar = '/img_setting/noimage/df.jpg'; $nama = $useavatar->EMP_NM; } else { # code... $nama = $useavatar->EMP_NM; $gambaravatar = 'data:image/jpg;charset=utf-8;base64,' . $useavatar->IMG_BASE64; } } elseif ($params['chat'] == 'group') { # code... $group_id = $params['ChatSearch']['GROUP']; $useavatar = Chatroom::find()->where(['GROUP_ID' => $group_id])->one(); $nama = $useavatar->GROUP_NM; $gambaravatar = 'data:image/jpg;charset=utf-8;base64,' . $useavatar->IMAGE64; } else { $emp_chat_id = $params['ChatSearch']['GROUP']; $useavatar = Employe::find()->where(['EMP_ID' => $emp_chat_id])->one(); if ($useavatar->IMG_BASE64 == '') { $nama = $useavatar->EMP_NM; $gambaravatar = '/img_setting/noimage/df.jpg'; } else { # code... $nama = $useavatar->EMP_NM; $gambaravatar = 'data:image/jpg;charset=utf-8;base64,' . $useavatar->IMG_BASE64; } } ?>
public function getChat() { return $this->hasOne(Chatroom::className(), ['GROUP_ID' => 'GROUP_ID']); }
/** * Finds the Chatroom model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Chatroom the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Chatroom::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }