@@ 22-47 (lines=26) @@ | ||
19 | const ITEM_PER_PAGE = 10; |
|
20 | ||
21 | // profile list |
|
22 | public function actionIndex() |
|
23 | { |
|
24 | // init Active Record |
|
25 | $query = new ProfileRecords(); |
|
26 | ||
27 | // set current page and offset |
|
28 | $page = (int)App::$Request->query->get('page'); |
|
29 | $offset = $page * self::ITEM_PER_PAGE; |
|
30 | ||
31 | // build pagination |
|
32 | $pagination = new SimplePagination([ |
|
33 | 'url' => ['profile/index'], |
|
34 | 'page' => $page, |
|
35 | 'step' => self::ITEM_PER_PAGE, |
|
36 | 'total' => $query->count() |
|
37 | ]); |
|
38 | ||
39 | // build listing objects |
|
40 | $records = $query->orderBy('id', 'desc')->skip($offset)->take(self::ITEM_PER_PAGE)->get(); |
|
41 | ||
42 | // display viewer |
|
43 | $this->response = App::$View->render('index', [ |
|
44 | 'records' => $records, |
|
45 | 'pagination' => $pagination |
|
46 | ]); |
|
47 | } |
|
48 | ||
49 | // redirect delete action to user controller |
|
50 | public function actionDelete($id) |
@@ 23-48 (lines=26) @@ | ||
20 | const ITEM_PER_PAGE = 10; |
|
21 | ||
22 | // list users |
|
23 | public function actionIndex() |
|
24 | { |
|
25 | // init Active Record |
|
26 | $query = new UserRecords(); |
|
27 | ||
28 | // set current page and offset |
|
29 | $page = (int)App::$Request->query->get('page'); |
|
30 | $offset = $page * self::ITEM_PER_PAGE; |
|
31 | ||
32 | // build pagination |
|
33 | $pagination = new SimplePagination([ |
|
34 | 'url' => ['user/index'], |
|
35 | 'page' => $page, |
|
36 | 'step' => self::ITEM_PER_PAGE, |
|
37 | 'total' => $query->count() |
|
38 | ]); |
|
39 | ||
40 | // build listing objects |
|
41 | $records = $query->orderBy('id', 'desc')->skip($offset)->take(self::ITEM_PER_PAGE)->get(); |
|
42 | ||
43 | // display viewer |
|
44 | $this->response = App::$View->render('index', [ |
|
45 | 'records' => $records, |
|
46 | 'pagination' => $pagination |
|
47 | ]); |
|
48 | } |
|
49 | ||
50 | // edit user profiles |
|
51 | public function actionUpdate($id) |