public function actionIndex()
    {
        $userId = Yii::$app->getUser()->getId();
        $query = (new Query())
            ->from('{{%notifications}}')
            ->andWhere(['or', 'user_id = 0', 'user_id = :user_id'], [':user_id' => $userId]);

        $pagination = new Pagination([
            'pageSize' => 20,
            'totalCount' => $query->count(),
        ]);

        $list = $query
            ->orderBy(['id' => SORT_DESC])
            ->offset($pagination->offset)
            ->limit($pagination->limit)
            ->all();

        $notifs = $this->prepareNotifications($list);

        return $this->render('index', [
            'notifications' => $notifs,
            'pagination' => $pagination,
        ]);
    }
public function actionIndex()
    {
        $userId = Yii::$app->getUser()->getId();
        $query = (new Query())
            ->from('{{%notifications}}')
            ->andWhere(['or', 'user_id = 0', 'user_id = :user_id'], [':user_id' => $userId]);

        $pagination = new Pagination([
            'pageSize' => 20,
            'totalCount' => $query->count(),
        ]);

        $list = $query
            ->orderBy(['id' => SORT_DESC])
            ->offset($pagination->offset)
            ->limit($pagination->limit)
            ->all();

        $notifs = $this->prepareNotifications($list);

        return $this->render('index', [
            'notifications' => $notifs,
            'pagination' => $pagination,
        ]);
    }
public function actionIndex ( ) { $ userId = Yii :: $ app -> getUser ( ) -> getId ( ) ; $ query = ( new Query ( ) ) -> from ( '{{%notifications}}' ) -> andWhere ( [ 'or' , 'user_id = 0' , 'user_id = :user_id' ] , [ ':user_id' => $ userId ] ) ; $ pagination = new Pagination ( [ 'pageSize' => 20 , 'totalCount' => $ query -> count ( ) , ] ) ; $ list = $ query -> orderBy ( [ 'id' => SORT_DESC ] ) -> offset ( $ pagination -> offset ) -> limit ( $ pagination -> limit ) -> all ( ) ; $ notifs = $ this -> prepareNotifications ( $ list ) ; return $ this -> render ( 'index' , [ 'notifications' => $ notifs , 'pagination' => $ pagination , ] ) ; }
Displays index page.

@return string
Displays index page .