1 | <?php |
||
22 | class EloquentRepository extends BaseRepository |
||
23 | { |
||
24 | /** |
||
25 | * Create a new repository model instance. |
||
26 | * |
||
27 | * @throws \Rinvex\Repository\Exceptions\RepositoryException |
||
28 | * |
||
29 | * @return \Illuminate\Database\Eloquent\Model |
||
30 | */ |
||
31 | public function createModel() |
||
47 | |||
48 | /** |
||
49 | * Find an entity by it's primary key. |
||
50 | * |
||
51 | * @param int $id |
||
52 | * @param array $attributes |
||
53 | * |
||
54 | * @return \Illuminate\Database\Eloquent\Model |
||
55 | */ |
||
56 | public function find($id, $attributes = ['*']) |
||
62 | |||
63 | /** |
||
64 | * Find an entity by one of it's attributes. |
||
65 | * |
||
66 | * @param string $attribute |
||
67 | * @param string $value |
||
68 | * @param array $attributes |
||
69 | * |
||
70 | * @return \Illuminate\Database\Eloquent\Model |
||
71 | */ |
||
72 | public function findBy($attribute, $value, $attributes = ['*']) |
||
78 | |||
79 | /** |
||
80 | * Find the first entity. |
||
81 | * |
||
82 | * @param array $attributes |
||
83 | * |
||
84 | * @return \Illuminate\Database\Eloquent\Model |
||
85 | */ |
||
86 | public function findFirst($attributes = ['*']) |
||
92 | |||
93 | /** |
||
94 | * Find all entities. |
||
95 | * |
||
96 | * @param array $attributes |
||
97 | * |
||
98 | * @return \Illuminate\Support\Collection |
||
99 | */ |
||
100 | public function findAll($attributes = ['*']) |
||
106 | |||
107 | /** |
||
108 | * Paginate all entities. |
||
109 | * |
||
110 | * @param int|null $perPage |
||
111 | * @param array $attributes |
||
112 | * @param string $pageName |
||
113 | * @param int|null $page |
||
114 | * |
||
115 | * @throws \InvalidArgumentException |
||
116 | * |
||
117 | * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator |
||
118 | */ |
||
119 | public function paginate($perPage = null, $attributes = ['*'], $pageName = 'page', $page = null) |
||
127 | |||
128 | /** |
||
129 | * Paginate all entities into a simple paginator. |
||
130 | * |
||
131 | * @param int|null $perPage |
||
132 | * @param array $attributes |
||
133 | * @param string $pageName |
||
134 | * @param int|null $page |
||
135 | * |
||
136 | * @return \Illuminate\Contracts\Pagination\Paginator |
||
137 | */ |
||
138 | public function simplePaginate($perPage = null, $attributes = ['*'], $pageName = 'page', $page = null) |
||
146 | |||
147 | /** |
||
148 | * Find all entities matching where conditions. |
||
149 | * |
||
150 | * @param array $where |
||
151 | * @param array $attributes |
||
152 | * |
||
153 | * @return \Illuminate\Support\Collection |
||
154 | */ |
||
155 | public function findWhere(array $where, $attributes = ['*']) |
||
165 | |||
166 | /** |
||
167 | * Find all entities matching whereIn conditions. |
||
168 | * |
||
169 | * @param array $where |
||
170 | * @param array $attributes |
||
171 | * |
||
172 | * @return \Illuminate\Support\Collection |
||
173 | */ |
||
174 | public function findWhereIn(array $where, $attributes = ['*']) |
||
184 | |||
185 | /** |
||
186 | * Find all entities matching whereNotIn conditions. |
||
187 | * |
||
188 | * @param array $where |
||
189 | * @param array $attributes |
||
190 | * |
||
191 | * @return \Illuminate\Support\Collection |
||
192 | */ |
||
193 | public function findWhereNotIn(array $where, $attributes = ['*']) |
||
203 | |||
204 | /** |
||
205 | * Add a relationship count / exists condition to the query with where clauses. |
||
206 | * |
||
207 | * @param array $where |
||
208 | * @param array $attributes |
||
209 | * |
||
210 | * @return \Illuminate\Database\Eloquent\Builder|static |
||
211 | */ |
||
212 | public function findWhereHas(array $where, $attributes = ['*']) |
||
222 | |||
223 | /** |
||
224 | * Create a new entity with the given attributes. |
||
225 | * |
||
226 | * @param array $attributes |
||
227 | * |
||
228 | * @return array |
||
229 | */ |
||
230 | public function create(array $attributes = []) |
||
250 | |||
251 | /** |
||
252 | * Update an entity with the given attributes. |
||
253 | * |
||
254 | * @param mixed $id |
||
255 | * @param array $attributes |
||
256 | * |
||
257 | * @return array |
||
258 | */ |
||
259 | public function update($id, array $attributes = []) |
||
280 | |||
281 | /** |
||
282 | * Delete an entity with the given id. |
||
283 | * |
||
284 | * @param mixed $id |
||
285 | * |
||
286 | * @return array |
||
287 | */ |
||
288 | public function delete($id) |
||
309 | } |
||
310 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.