Ejemplo n.º 1
0
 public function actionNotifications()
 {
     $myId = Yii::$app->getUser()->id;
     Notice::updateAll(['updated_at' => time(), 'status' => 1], ['status' => 0, 'target_id' => $myId]);
     $query = Notice::find()->where(['target_id' => $myId]);
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count('id')]);
     $notices = $query->orderBy(['id' => SORT_DESC])->offset($pages->offset)->with(['source', 'topic'])->limit($pages->limit)->asArray()->all();
     return $this->render('notifications', ['notices' => $notices, 'pages' => $pages]);
 }