1 | <?php namespace Modules\Core\Repositories\Eloquent; |
||
11 | abstract class EloquentBaseRepository implements BaseRepository |
||
12 | { |
||
13 | /** |
||
14 | * @var Model An instance of the Eloquent Model |
||
15 | */ |
||
16 | protected $model; |
||
17 | |||
18 | /** |
||
19 | * @param Model $model |
||
20 | */ |
||
21 | public function __construct($model) |
||
25 | |||
26 | /** |
||
27 | * @param int $id |
||
28 | * @return object |
||
29 | */ |
||
30 | public function find($id) |
||
38 | |||
39 | /** |
||
40 | * @return \Illuminate\Database\Eloquent\Collection |
||
41 | */ |
||
42 | public function all() |
||
50 | |||
51 | /** |
||
52 | * @param mixed $data |
||
53 | * @return object |
||
54 | */ |
||
55 | public function create($data) |
||
59 | |||
60 | /** |
||
61 | * @param $model |
||
62 | * @param array $data |
||
63 | * @return object |
||
64 | */ |
||
65 | public function update($model, $data) |
||
71 | |||
72 | /** |
||
73 | * @param Model $model |
||
74 | * @return bool |
||
75 | */ |
||
76 | public function destroy($model) |
||
80 | |||
81 | /** |
||
82 | * Return all resources in the given language |
||
83 | * |
||
84 | * @param string $lang |
||
85 | * @return \Illuminate\Database\Eloquent\Collection |
||
86 | */ |
||
87 | public function allTranslatedIn($lang) |
||
93 | |||
94 | /** |
||
95 | * Find a resource by the given slug |
||
96 | * |
||
97 | * @param string $slug |
||
98 | * @return object |
||
99 | */ |
||
100 | public function findBySlug($slug) |
||
110 | |||
111 | /** |
||
112 | * Find a resource by an array of attributes |
||
113 | * @param array $attributes |
||
114 | * @return object |
||
115 | */ |
||
116 | public function findByAttributes(array $attributes) |
||
122 | |||
123 | /** |
||
124 | * Get resources by an array of attributes |
||
125 | * @param array $attributes |
||
126 | * @return objects |
||
127 | */ |
||
128 | public function getByAttributes(array $attributes, $orderBy = '', $sort = 'asc') |
||
134 | |||
135 | /** |
||
136 | * Build Query to catch resources by an array of attributes and params |
||
137 | * @param array $attributes |
||
138 | * @return query object |
||
139 | */ |
||
140 | private function catchByAttributes(array $attributes, $orderBy = '', $sort = 'asc') |
||
158 | |||
159 | /** |
||
160 | * Return a collection of elements who's ids match |
||
161 | * @param array $ids |
||
162 | * @return mixed |
||
163 | */ |
||
164 | public function findByMany(array $ids) |
||
174 | |||
175 | /** |
||
176 | * Clear the cache for this Repositories' Entity |
||
177 | * @return bool |
||
178 | */ |
||
179 | public function clearCache() |
||
183 | } |
||
184 |