| Conditions | 1 |
| Paths | 1 |
| Total Lines | 26 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | public function index(): ?string |
||
| 24 | { |
||
| 25 | // init Active Record |
||
| 26 | $query = Profile::with(['user']); |
||
| 27 | |||
| 28 | // set current page and offset |
||
| 29 | $page = (int)$this->request->query->get('page'); |
||
| 30 | $offset = $page * self::ITEM_PER_PAGE; |
||
|
|
|||
| 31 | |||
| 32 | // count total items count for pagination builder |
||
| 33 | $total = $query->count(); |
||
| 34 | |||
| 35 | // build listing objects |
||
| 36 | $records = $query->orderBy('id', 'desc') |
||
| 37 | ->skip($offset) |
||
| 38 | ->take(self::ITEM_PER_PAGE) |
||
| 39 | ->get(); |
||
| 40 | |||
| 41 | // display viewer |
||
| 42 | return $this->view->render('profile/index', [ |
||
| 43 | 'records' => $records, |
||
| 44 | 'pagination' => [ |
||
| 45 | 'url' => ['profile/index'], |
||
| 46 | 'page' => $page, |
||
| 47 | 'step' => self::ITEM_PER_PAGE, |
||
| 48 | 'total' => $total |
||
| 49 | ] |
||
| 52 | } |