1 | <?php namespace Modules\Blog\Repositories\Eloquent; |
||
10 | class EloquentPostRepository extends EloquentBaseRepository implements PostRepository |
||
11 | { |
||
12 | /** |
||
13 | * @param int $id |
||
14 | * @return object |
||
15 | */ |
||
16 | public function find($id) |
||
17 | { |
||
18 | return $this->model->with('translations', 'tags')->find($id); |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * @return \Illuminate\Database\Eloquent\Collection |
||
23 | */ |
||
24 | public function all() |
||
25 | { |
||
26 | return $this->model->with('translations', 'tags')->orderBy('created_at', 'DESC')->get(); |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * Update a resource |
||
31 | * @param $post |
||
32 | * @param array $data |
||
33 | * @return mixed |
||
34 | */ |
||
35 | public function update($post, $data) |
||
45 | |||
46 | /** |
||
47 | * Create a blog post |
||
48 | * @param array $data |
||
49 | * @return Post |
||
50 | */ |
||
51 | public function create($data) |
||
61 | |||
62 | /** |
||
63 | * Return all resources in the given language |
||
64 | * |
||
65 | * @param string $lang |
||
66 | * @return \Illuminate\Database\Eloquent\Collection |
||
67 | */ |
||
68 | public function allTranslatedIn($lang) |
||
75 | |||
76 | /** |
||
77 | * Return the latest x blog posts |
||
78 | * @param int $amount |
||
79 | * @return Collection |
||
80 | */ |
||
81 | public function latest($amount = 5) |
||
85 | |||
86 | /** |
||
87 | * Get the previous post of the given post |
||
88 | * @param object $post |
||
89 | * @return object |
||
90 | */ |
||
91 | public function getPreviousOf($post) |
||
96 | |||
97 | /** |
||
98 | * Get the next post of the given post |
||
99 | * @param object $post |
||
100 | * @return object |
||
101 | */ |
||
102 | public function getNextOf($post) |
||
107 | |||
108 | /** |
||
109 | * Find a resource by the given slug |
||
110 | * |
||
111 | * @param string $slug |
||
112 | * @return object |
||
113 | */ |
||
114 | public function findBySlug($slug) |
||
120 | } |
||
121 |