]> BookStack Code Mirror - bookstack/blob - app/Repos/EntityRepo.php
Closes #69. Implemented and tested memcached.
[bookstack] / app / Repos / EntityRepo.php
1 <?php namespace BookStack\Repos;
2
3
4 use BookStack\Book;
5 use BookStack\Chapter;
6 use BookStack\Page;
7
8 class EntityRepo
9 {
10
11     public $book;
12     public $chapter;
13     public $page;
14
15     /**
16      * EntityService constructor.
17      * @param $book
18      * @param $chapter
19      * @param $page
20      */
21     public function __construct(Book $book, Chapter $chapter, Page $page)
22     {
23         $this->book = $book;
24         $this->chapter = $chapter;
25         $this->page = $page;
26     }
27
28     /**
29      * Get the latest books added to the system.
30      * @param $count
31      * @param $page
32      */
33     public function getRecentlyCreatedBooks($count = 20, $page = 0)
34     {
35         return $this->book->orderBy('created_at', 'desc')->skip($page*$count)->take($count)->get();
36     }
37
38     /**
39      * Get the most recently updated books.
40      * @param $count
41      * @param int $page
42      * @return mixed
43      */
44     public function getRecentlyUpdatedBooks($count = 20, $page = 0)
45     {
46         return $this->book->orderBy('updated_at', 'desc')->skip($page*$count)->take($count)->get();
47     }
48
49     /**
50      * Get the latest pages added to the system.
51      * @param $count
52      * @param $page
53      */
54     public function getRecentlyCreatedPages($count = 20, $page = 0)
55     {
56         return $this->page->orderBy('created_at', 'desc')->skip($page*$count)->take($count)->get();
57     }
58
59     /**
60      * Get the most recently updated pages.
61      * @param $count
62      * @param int $page
63      * @return mixed
64      */
65     public function getRecentlyUpdatedPages($count = 20, $page = 0)
66     {
67         return $this->page->orderBy('updated_at', 'desc')->skip($page*$count)->take($count)->get();
68     }
69
70
71 }