public function actionNotification() { $new_msg = Inbox::find()->unread()->asArray()->all(); $result = []; $result['count'] = count($new_msg); $result['items'] = $new_msg; echo Json::encode($result); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Inbox::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['UpdatedInDB' => $this->UpdatedInDB, 'ReceivingDateTime' => $this->ReceivingDateTime, 'Class' => $this->Class, 'ID' => $this->ID]); $query->andFilterWhere(['like', 'Text', $this->Text])->andFilterWhere(['like', 'SenderNumber', $this->SenderNumber])->andFilterWhere(['like', 'Coding', $this->Coding])->andFilterWhere(['like', 'UDH', $this->UDH])->andFilterWhere(['like', 'SMSCNumber', $this->SMSCNumber])->andFilterWhere(['like', 'TextDecoded', $this->TextDecoded])->andFilterWhere(['like', 'RecipientID', $this->RecipientID])->andFilterWhere(['like', 'Processed', $this->Processed]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Inbox::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(['id' => $this->id, 'date_received' => $this->date_received, 'read' => $this->read]); $query->orFilterWhere(['ilike', 'sender', $this->searchModel])->orFilterWhere(['ilike', 'recipient', $this->searchModel])->orFilterWhere(['ilike', 'message_text', $this->searchModel])->orFilterWhere(['ilike', 'recipient_type', $this->searchModel]); return $dataProvider; }
/** * Finds the Inbox model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Inbox the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Inbox::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }