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