/**
  * Finds the Notifications model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Notifications the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Notifications::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #2
0
 /**
  * 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;
 }
예제 #3
0
 /**
  * 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;
 }
예제 #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getNotifications()
 {
     return $this->hasMany(Notifications::className(), ['user_id' => 'id']);
 }
예제 #5
0
<?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>&nbsp;<?php 
    echo Yii::t('app', 'Latest Notifications') . '&nbsp;(' . 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';
        ?>