Conditions | 2 |
Paths | 2 |
Total Lines | 31 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
24 | public function feed(): ?string |
||
25 | { |
||
26 | /** @var array $cfg */ |
||
27 | $cfg = $this->application->configs; |
||
28 | // get pagination page id and calc offset |
||
29 | $page = (int)$this->request->query->get('page'); |
||
30 | if ((int)$cfg['wallPostOnFeed'] >= 1) { |
||
31 | $items = (int)$cfg['wallPostOnFeed']; |
||
|
|||
32 | } |
||
33 | // calc offset |
||
34 | $offset = $page * static::FEED_PER_PAGE; |
||
35 | |||
36 | // total wall posts count |
||
37 | $query = new WallPost(); |
||
38 | // get total items count |
||
39 | $total = $query->count(); |
||
40 | |||
41 | // get records from database as object related with User, Role, Profile objects |
||
42 | $records = $query->with(['senderUser', 'senderUser.role', 'senderUser.profile']) |
||
43 | ->orderBy('id', 'DESC') |
||
44 | ->skip($offset) |
||
45 | ->take(static::FEED_PER_PAGE) |
||
46 | ->get(); |
||
47 | |||
48 | // render output view |
||
49 | return $this->view->render('profile/feed', [ |
||
50 | 'records' => $records, |
||
51 | 'pagination' => [ |
||
52 | 'step' => static::FEED_PER_PAGE, |
||
53 | 'total' => $total, |
||
54 | 'page' => $page |
||
55 | ], |
||
59 |