1 | <?php namespace Anomaly\Streams\Platform\Model; |
||
17 | class EloquentRepository implements EloquentRepositoryInterface |
||
18 | { |
||
19 | |||
20 | use FiresCallbacks; |
||
21 | use Hookable; |
||
22 | |||
23 | /** |
||
24 | * Return all records. |
||
25 | * |
||
26 | * @return EloquentCollection |
||
27 | */ |
||
28 | public function all() |
||
32 | |||
33 | /** |
||
34 | * Find a record by it's ID. |
||
35 | * |
||
36 | * @param $id |
||
37 | * @return EloquentModel |
||
38 | */ |
||
39 | public function find($id) |
||
43 | |||
44 | /** |
||
45 | * Find all records by IDs. |
||
46 | * |
||
47 | * @param array $ids |
||
48 | * @return EloquentCollection |
||
49 | */ |
||
50 | public function findAll(array $ids) |
||
54 | |||
55 | /** |
||
56 | * Find a trashed record by it's ID. |
||
57 | * |
||
58 | * @param $id |
||
59 | * @return null|EloquentModel |
||
60 | */ |
||
61 | public function findTrashed($id) |
||
69 | |||
70 | /** |
||
71 | * Create a new record. |
||
72 | * |
||
73 | * @param array $attributes |
||
74 | * @return EloquentModel |
||
75 | */ |
||
76 | public function create(array $attributes) |
||
80 | |||
81 | /** |
||
82 | * Return a new query builder. |
||
83 | * |
||
84 | * @return Builder |
||
85 | */ |
||
86 | public function newQuery() |
||
90 | |||
91 | /** |
||
92 | * Return a new instance. |
||
93 | * |
||
94 | * @return EloquentModel |
||
95 | */ |
||
96 | public function newInstance() |
||
100 | |||
101 | /** |
||
102 | * Count all records. |
||
103 | * |
||
104 | * @return int |
||
105 | */ |
||
106 | public function count() |
||
110 | |||
111 | /** |
||
112 | * Return a paginated collection. |
||
113 | * |
||
114 | * @param array $parameters |
||
115 | * @return LengthAwarePaginator |
||
116 | */ |
||
117 | public function paginate(array $parameters = []) |
||
160 | |||
161 | /** |
||
162 | * Save a record. |
||
163 | * |
||
164 | * @param EloquentModel $entry |
||
165 | * @return bool |
||
166 | */ |
||
167 | public function save(EloquentModel $entry) |
||
171 | |||
172 | /** |
||
173 | * Update multiple records. |
||
174 | * |
||
175 | * @param array $attributes |
||
176 | * @return bool |
||
177 | */ |
||
178 | public function update(array $attributes = []) |
||
182 | |||
183 | /** |
||
184 | * Delete a record. |
||
185 | * |
||
186 | * @param EloquentModel $entry |
||
187 | * @return bool |
||
188 | */ |
||
189 | public function delete(EloquentModel $entry) |
||
193 | |||
194 | /** |
||
195 | * Force delete a record. |
||
196 | * |
||
197 | * @param EloquentModel $entry |
||
198 | * @return bool |
||
199 | */ |
||
200 | public function forceDelete(EloquentModel $entry) |
||
209 | |||
210 | /** |
||
211 | * Restore a trashed record. |
||
212 | * |
||
213 | * @param EloquentModel $entry |
||
214 | * @return bool |
||
215 | */ |
||
216 | public function restore(EloquentModel $entry) |
||
220 | |||
221 | /** |
||
222 | * Truncate the entries. |
||
223 | * |
||
224 | * @return $this |
||
225 | */ |
||
226 | public function truncate() |
||
249 | |||
250 | /** |
||
251 | * Set the model. |
||
252 | * |
||
253 | * @param EloquentModel $model |
||
254 | * @return $this |
||
255 | */ |
||
256 | public function setModel(EloquentModel $model) |
||
262 | |||
263 | /** |
||
264 | * Get the model. |
||
265 | * |
||
266 | * @return EloquentModel |
||
267 | */ |
||
268 | public function getModel() |
||
272 | |||
273 | /** |
||
274 | * Pipe non-existing calls through hooks. |
||
275 | * |
||
276 | * @param $method |
||
277 | * @param $parameters |
||
278 | * @return mixed|null |
||
279 | */ |
||
280 | public function __call($method, $parameters) |
||
288 | } |
||
289 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: