@@ 44-69 (lines=26) @@ | ||
41 | * |
|
42 | * @return void |
|
43 | */ |
|
44 | public function index() |
|
45 | { |
|
46 | $this->loadModel('BlogArticles'); |
|
47 | $this->paginate = [ |
|
48 | 'maxLimit' => Configure::read('Blog.article_per_page') |
|
49 | ]; |
|
50 | ||
51 | $articles = $this->BlogArticles |
|
52 | ->find() |
|
53 | ->contain([ |
|
54 | 'BlogCategories', |
|
55 | 'Users' => function ($q) { |
|
56 | return $q->find('short'); |
|
57 | } |
|
58 | ]) |
|
59 | ->order([ |
|
60 | 'BlogArticles.created' => 'desc' |
|
61 | ]) |
|
62 | ->where([ |
|
63 | 'BlogArticles.is_display' => 1 |
|
64 | ]); |
|
65 | ||
66 | $articles = $this->paginate($articles); |
|
67 | ||
68 | $this->set(compact('articles')); |
|
69 | } |
|
70 | ||
71 | /** |
|
72 | * Display a specific category with all its articles. |
@@ 639-663 (lines=25) @@ | ||
636 | * |
|
637 | * @return void |
|
638 | */ |
|
639 | public function notifications() |
|
640 | { |
|
641 | $this->loadModel('Notifications'); |
|
642 | ||
643 | $this->paginate = [ |
|
644 | 'maxLimit' => Configure::read('User.notifications_per_page') |
|
645 | ]; |
|
646 | ||
647 | $notifications = $this->Notifications |
|
648 | ->find() |
|
649 | ->where([ |
|
650 | 'user_id' => $this->Auth->user('id') |
|
651 | ]) |
|
652 | ->order([ |
|
653 | 'is_read' => 'ASC', |
|
654 | 'created' => 'DESC' |
|
655 | ]) |
|
656 | ->find('map', [ |
|
657 | 'session' => $this->request->session() |
|
658 | ]); |
|
659 | ||
660 | $notifications = $this->paginate($notifications); |
|
661 | ||
662 | $this->set(compact('notifications')); |
|
663 | } |
|
664 | ||
665 | /** |
|
666 | * Display the form to reset the password. |