Esempio n. 1
0
 /**
  * List feedback requests messages from authorized user
  * @return string
  * @throws \Ffcms\Core\Exception\NativeException
  * @throws ForbiddenException
  * @throws \Ffcms\Core\Exception\SyntaxException
  */
 public function actionList()
 {
     // set current page and offset
     $page = (int) $this->request->query->get('page');
     $offset = $page * self::ITEM_PER_PAGE;
     // check if user is authorized or throw exception
     if (!App::$User->isAuth()) {
         throw new ForbiddenException(__('Feedback listing available only for authorized users'));
     }
     // get current user object
     $user = App::$User->identity();
     // initialize query with major condition
     $query = FeedbackPost::where('user_id', '=', $user->getId());
     // build pagination
     $pagination = new SimplePagination(['url' => ['feedback/list'], 'page' => $page, 'step' => self::ITEM_PER_PAGE, 'total' => $query->count()]);
     // build records object from prepared query using page offset
     $records = $query->orderBy('id', 'desc')->skip($offset)->take(self::ITEM_PER_PAGE)->get();
     // render viewer with parameters
     return $this->view->render('list', ['records' => $records, 'pagination' => $pagination]);
 }
Esempio n. 2
0
 /**
  * Calculate unreaded feedback
  */
 private function calcNewFeedback()
 {
     $this->feedback = FeedbackPost::where('readed', '=', 0)->where('closed', '=', 0)->count();
 }