1 | <?php |
||
8 | abstract class EloquentBaseRepository extends RepositoryAbstract implements EloquentRepositoryInterface |
||
9 | { |
||
10 | /** |
||
11 | * BaseRepository constructor. |
||
12 | */ |
||
13 | public function __construct() |
||
17 | |||
18 | /** |
||
19 | * Get all records. |
||
20 | * |
||
21 | * @return \Illuminate\Database\Eloquent\Collection |
||
22 | */ |
||
23 | public function all() |
||
27 | |||
28 | /** |
||
29 | * Paginate records. |
||
30 | * |
||
31 | * @param int $limit |
||
32 | * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator |
||
33 | */ |
||
34 | public function paginate($limit = 10) |
||
38 | |||
39 | /** |
||
40 | * Save a new entity in repository. |
||
41 | * |
||
42 | * @param array $attributes |
||
43 | * @return mixed |
||
44 | */ |
||
45 | public function create(array $attributes) |
||
54 | |||
55 | /** |
||
56 | * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model |
||
57 | */ |
||
58 | public function resetModel() |
||
62 | |||
63 | /** |
||
64 | * Make a new entity in repository. |
||
65 | * |
||
66 | * @param array $attributes |
||
67 | * @return \Illuminate\Database\Eloquent\Model |
||
68 | */ |
||
69 | public function make(array $attributes) |
||
73 | |||
74 | /** |
||
75 | * Update a entity in repository by id. |
||
76 | * |
||
77 | * @param array $attributes |
||
78 | * @param int $id |
||
79 | * @return \Illuminate\Database\Eloquent\Model |
||
80 | */ |
||
81 | public function update(array $attributes, $id) |
||
95 | |||
96 | /** |
||
97 | * Delete a entity in repository by id. |
||
98 | * |
||
99 | * @param int $id |
||
100 | * @return bool|null |
||
101 | * @throws \Exception |
||
102 | */ |
||
103 | public function delete($id) |
||
114 | |||
115 | /** |
||
116 | * Find data by id. |
||
117 | * |
||
118 | * @param int $id |
||
119 | * @param array $columns |
||
120 | * @return \Illuminate\Database\Eloquent\Model |
||
121 | * @throws ModelNotFoundException |
||
122 | */ |
||
123 | public function find($id, $columns = ['*']) |
||
130 | |||
131 | /** |
||
132 | * Set repository model instance. |
||
133 | * |
||
134 | * @param \Illuminate\Database\Eloquent\Model $model |
||
135 | * @return $this |
||
136 | */ |
||
137 | public function forModel(Model $model) |
||
143 | |||
144 | /** |
||
145 | * Count all records. |
||
146 | * |
||
147 | * @return int |
||
148 | */ |
||
149 | public function count() |
||
153 | } |
||
154 |