/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Notifications::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]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'text', $this->text])->andFilterWhere(['like', 'type', $this->type]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Notifications::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, 'user_id' => $this->user_id, 'alias' => $this->alias, 'is_read' => $this->is_read, 'notification_time' => $this->notification_time]); $query->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'alias2', $this->alias2])->andFilterWhere(['like', 'body', $this->body]); return $dataProvider; }
<?php /* @var $this \yii\web\View */ /* @var $content string */ use yii\helpers\Html; use yii\helpers\Url; $notify_count = \common\models\Notifications::find()->where(array('user_id' => Yii::$app->user->id))->all(); $notifications = \common\models\Notifications::find()->where(array('user_id' => Yii::$app->user->id))->limit(5)->all(); if (count($notify_count) > 0) { ?> <span class="title_holder_home"> <h3><i class="fa fa-bell-o"></i> <?php echo Yii::t('app', 'Latest Notifications') . ' (' . count($notify_count) . ')'; ?> </h3> </span> <?php foreach ($notifications as $notify) { $notification = $notify->notifyText(); $icon = $notification['icon']; $color = $notification['color']; $notify_title = $notification['notify_title']; $notify_text = $notification['notify_text']; $formatter = \Yii::$app->formatter; ?> <li class="notification_list"> <span class="marginalized"> <h6 style="<?php echo $notify->is_read == 0 ? '' : 'color:#bbb'; ?>