1 | <?php |
||
18 | abstract class Repository implements Contract |
||
|
|||
19 | { |
||
20 | protected $with = []; |
||
21 | /** |
||
22 | * @var App |
||
23 | */ |
||
24 | protected $app; |
||
25 | |||
26 | /** @var string */ |
||
27 | protected $order = null; |
||
28 | |||
29 | protected $direction = 'desc'; |
||
30 | /** |
||
31 | * @var Entity |
||
32 | */ |
||
33 | protected $model; |
||
34 | /** |
||
35 | * @var boolean |
||
36 | */ |
||
37 | private $trash = false; |
||
38 | /** |
||
39 | * @var boolean |
||
40 | */ |
||
41 | private $withTrash = false; |
||
42 | |||
43 | /** |
||
44 | * @param App $app |
||
45 | */ |
||
46 | public function __construct(App $app) |
||
51 | |||
52 | protected function makeModel() |
||
56 | |||
57 | /** |
||
58 | * @return string |
||
59 | */ |
||
60 | abstract protected function getModelClass(): string; |
||
61 | |||
62 | /** |
||
63 | * @param int $limit |
||
64 | * @param array $filters |
||
65 | * |
||
66 | * @return \Illuminate\Contracts\Pagination\Paginator |
||
67 | */ |
||
68 | public function simplePaginate($limit = 10, $filters = []) |
||
72 | |||
73 | /** |
||
74 | * @param array $filters |
||
75 | * @return Entity |
||
76 | */ |
||
77 | public function filter($filters = []) |
||
113 | |||
114 | /** |
||
115 | * @param int $limit |
||
116 | * @param array $filters |
||
117 | * |
||
118 | * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator |
||
119 | */ |
||
120 | public function paginate($limit = 10, $filters = []) |
||
124 | |||
125 | /** |
||
126 | * @param array $filters |
||
127 | * |
||
128 | * @return Builder[]|\Illuminate\Database\Eloquent\Collection |
||
129 | */ |
||
130 | public function get($filters = []) |
||
134 | |||
135 | /** |
||
136 | * @param $entityId |
||
137 | * @param array $attributes |
||
138 | * |
||
139 | * @return bool |
||
140 | */ |
||
141 | public function update($entityId = 0, $attributes = []) |
||
151 | |||
152 | /** |
||
153 | * @param $entityId |
||
154 | * |
||
155 | * @throws \Exception |
||
156 | * |
||
157 | * @return bool |
||
158 | */ |
||
159 | public function delete($entityId = 0) |
||
169 | |||
170 | /** |
||
171 | * @param array $attributes |
||
172 | * |
||
173 | * @return bool |
||
174 | */ |
||
175 | public function insert($attributes = []) |
||
179 | |||
180 | |||
181 | /** |
||
182 | * @param array $columns |
||
183 | * |
||
184 | * @return mixed |
||
185 | */ |
||
186 | public function all($columns = ['*']) |
||
190 | |||
191 | /** |
||
192 | * @param string $name |
||
193 | * @param string $entityId |
||
194 | * @param array $filters |
||
195 | * |
||
196 | * @return array |
||
197 | */ |
||
198 | public function pluck($name = 'name', $entityId = 'id', $filters = []) |
||
202 | |||
203 | /** |
||
204 | * @param $entityId |
||
205 | * @param array $columns |
||
206 | * |
||
207 | * @return Entity |
||
208 | */ |
||
209 | public function find($entityId = 0, $columns = ['*']) |
||
213 | |||
214 | /** |
||
215 | * @param array $filter |
||
216 | * @param array $columns |
||
217 | * |
||
218 | * @return Entity |
||
219 | */ |
||
220 | public function first($filter = [], $columns = ['*']) |
||
224 | |||
225 | /** |
||
226 | * @param $haystack |
||
227 | * @param $needle |
||
228 | * |
||
229 | * @return Entity[]|\Illuminate\Database\Eloquent\Collection |
||
230 | */ |
||
231 | public function search($haystack, $needle) |
||
235 | |||
236 | |||
237 | /** |
||
238 | * @param $filters |
||
239 | * @param array $columns |
||
240 | * |
||
241 | * @return Entity |
||
242 | */ |
||
243 | public function findBy($filters = [], $columns = ['*']) |
||
247 | |||
248 | /** |
||
249 | * @param array $attributes |
||
250 | * |
||
251 | * @return Entity|\Illuminate\Database\Eloquent\Model |
||
252 | */ |
||
253 | public function create($attributes = []) |
||
257 | |||
258 | /** |
||
259 | * @param array $attributes |
||
260 | * |
||
261 | * @return Entity|\Illuminate\Database\Eloquent\Model |
||
262 | */ |
||
263 | public function createOrUpdate($attributes = []) |
||
267 | |||
268 | /** |
||
269 | * @param array $data |
||
270 | * |
||
271 | * @return \Illuminate\Database\Eloquent\Model |
||
272 | */ |
||
273 | public function createOrFirst($data = []) |
||
277 | |||
278 | /** |
||
279 | * Get entity name |
||
280 | * |
||
281 | * @return string |
||
282 | */ |
||
283 | public function entityName() |
||
287 | |||
288 | /** |
||
289 | * @param int $entityId |
||
290 | * |
||
291 | * @return bool|null |
||
292 | */ |
||
293 | public function restore($entityId = 0) |
||
305 | |||
306 | /** |
||
307 | * @param int $entityId |
||
308 | * |
||
309 | * @return bool|null |
||
310 | */ |
||
311 | public function forceDelete($entityId = 0) |
||
323 | |||
324 | /** |
||
325 | * @return void |
||
326 | */ |
||
327 | public function trash() |
||
332 | |||
333 | /** |
||
334 | * @return void |
||
335 | */ |
||
336 | public function withTrash() |
||
341 | } |
||
342 |
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.