1 | <?php |
||
2 | |||
3 | namespace Apps\Controller\Admin\User; |
||
4 | |||
5 | use Apps\ActiveRecord\Invite; |
||
6 | use Ffcms\Core\Arch\View; |
||
7 | use Ffcms\Core\Network\Request; |
||
8 | use Ffcms\Core\Network\Response; |
||
9 | |||
10 | /** |
||
11 | * Trait ActionInvite |
||
12 | * @package Apps\Controller\Admin\User |
||
13 | * @property Request $request |
||
14 | * @property Response $response |
||
15 | * @property View $view |
||
16 | */ |
||
17 | trait ActionInviteList |
||
18 | { |
||
19 | public function inviteList(): ?string |
||
20 | { |
||
21 | // init invite object |
||
22 | $record = new Invite(); |
||
23 | |||
24 | // set current page num and offset |
||
25 | $page = (int)$this->request->query->get('page', 0); |
||
26 | $offset = $page * self::ITEM_PER_PAGE; |
||
27 | |||
28 | // prepare pagination data |
||
29 | $pagination = [ |
||
30 | 'url' => ['user/invitelist'], |
||
31 | 'page' => $page, |
||
32 | 'step' => self::ITEM_PER_PAGE, |
||
33 | 'total' => $record->count() |
||
34 | ]; |
||
35 | |||
36 | // get invite list |
||
37 | $records = $record->orderBy('id', 'desc') |
||
38 | ->skip($offset) |
||
39 | ->take(self::ITEM_PER_PAGE) |
||
40 | ->get(); |
||
41 | |||
42 | return $this->view->render('user/invite_list', [ |
||
43 | 'records' => $records, |
||
44 | 'pagination' => $pagination, |
||
45 | 'configs' => $this->getConfigs() |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
46 | ]); |
||
47 | } |
||
48 | } |
||
49 |