| @@ 656-680 (lines=25) @@ | ||
| 653 | * |
|
| 654 | * @return void |
|
| 655 | */ |
|
| 656 | public function notifications() |
|
| 657 | { |
|
| 658 | $this->loadModel('Notifications'); |
|
| 659 | ||
| 660 | $this->paginate = [ |
|
| 661 | 'maxLimit' => Configure::read('User.notifications_per_page') |
|
| 662 | ]; |
|
| 663 | ||
| 664 | $notifications = $this->Notifications |
|
| 665 | ->find() |
|
| 666 | ->where([ |
|
| 667 | 'user_id' => $this->Auth->user('id') |
|
| 668 | ]) |
|
| 669 | ->order([ |
|
| 670 | 'is_read' => 'ASC', |
|
| 671 | 'created' => 'DESC' |
|
| 672 | ]) |
|
| 673 | ->find('map', [ |
|
| 674 | 'session' => $this->request->session() |
|
| 675 | ]); |
|
| 676 | ||
| 677 | $notifications = $this->paginate($notifications); |
|
| 678 | ||
| 679 | $this->set(compact('notifications')); |
|
| 680 | } |
|
| 681 | ||
| 682 | /** |
|
| 683 | * Display the form to reset the password. |
|
| @@ 45-70 (lines=26) @@ | ||
| 42 | * |
|
| 43 | * @return void |
|
| 44 | */ |
|
| 45 | public function index() |
|
| 46 | { |
|
| 47 | $this->loadModel('BlogArticles'); |
|
| 48 | $this->paginate = [ |
|
| 49 | 'maxLimit' => Configure::read('Blog.article_per_page') |
|
| 50 | ]; |
|
| 51 | ||
| 52 | $articles = $this->BlogArticles |
|
| 53 | ->find() |
|
| 54 | ->contain([ |
|
| 55 | 'BlogCategories', |
|
| 56 | 'Users' => function ($q) { |
|
| 57 | return $q->find('short'); |
|
| 58 | } |
|
| 59 | ]) |
|
| 60 | ->order([ |
|
| 61 | 'BlogArticles.created' => 'desc' |
|
| 62 | ]) |
|
| 63 | ->where([ |
|
| 64 | 'BlogArticles.is_display' => 1 |
|
| 65 | ]); |
|
| 66 | ||
| 67 | $articles = $this->paginate($articles); |
|
| 68 | ||
| 69 | $this->set(compact('articles')); |
|
| 70 | } |
|
| 71 | ||
| 72 | /** |
|
| 73 | * Display a specific category with all its articles. |
|
| @@ 23-50 (lines=28) @@ | ||
| 20 | * |
|
| 21 | * @return void |
|
| 22 | */ |
|
| 23 | public function index() |
|
| 24 | { |
|
| 25 | $this->loadModel('BlogArticles'); |
|
| 26 | ||
| 27 | $this->paginate = [ |
|
| 28 | 'maxLimit' => 15 |
|
| 29 | ]; |
|
| 30 | ||
| 31 | $articles = $this->BlogArticles |
|
| 32 | ->find() |
|
| 33 | ->contain([ |
|
| 34 | 'BlogCategories' => function ($q) { |
|
| 35 | return $q |
|
| 36 | ->select([ |
|
| 37 | 'id', |
|
| 38 | 'title' |
|
| 39 | ]); |
|
| 40 | }, |
|
| 41 | 'Users' => function ($q) { |
|
| 42 | return $q->find('short'); |
|
| 43 | } |
|
| 44 | ]) |
|
| 45 | ->order([ |
|
| 46 | 'BlogArticles.created' => 'desc' |
|
| 47 | ]); |
|
| 48 | ||
| 49 | $articles = $this->paginate($articles); |
|
| 50 | $this->set(compact('articles')); |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|