Conditions | 1 |
Paths | 1 |
Total Lines | 24 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
23 | public function index(): ?string |
||
24 | { |
||
25 | // set current page and offset |
||
26 | $page = (int)$this->request->query->get('page'); |
||
27 | $offset = $page * self::ITEM_PER_PAGE; |
||
|
|||
28 | |||
29 | // get feedback posts AR table |
||
30 | $query = FeedbackPost::with(['answers']); |
||
31 | $totalCount = $query->count(); |
||
32 | |||
33 | // build listing objects |
||
34 | $records = $query->orderBy('id', 'desc') |
||
35 | ->skip($offset) |
||
36 | ->take(self::ITEM_PER_PAGE) |
||
37 | ->get(); |
||
38 | |||
39 | // render output |
||
40 | return $this->view->render('feedback/index', [ |
||
41 | 'records' => $records, |
||
42 | 'pagination' => [ |
||
43 | 'url' => ['feedback/index'], |
||
44 | 'page' => $page, |
||
45 | 'step' => self::ITEM_PER_PAGE, |
||
46 | 'total' => $totalCount |
||
47 | ] |
||
51 |