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 instance. |
||
83 | * |
||
84 | * @return EloquentModel |
||
85 | */ |
||
86 | public function newInstance() |
||
90 | |||
91 | /** |
||
92 | * Count all records. |
||
93 | * |
||
94 | * @return int |
||
95 | */ |
||
96 | public function count() |
||
100 | |||
101 | /** |
||
102 | * Return a paginated collection. |
||
103 | * |
||
104 | * @param array $parameters |
||
105 | * @return LengthAwarePaginator |
||
106 | */ |
||
107 | public function paginate(array $parameters = []) |
||
150 | |||
151 | /** |
||
152 | * Save a record. |
||
153 | * |
||
154 | * @param EloquentModel $entry |
||
155 | * @return bool |
||
156 | */ |
||
157 | public function save(EloquentModel $entry) |
||
161 | |||
162 | /** |
||
163 | * Update multiple records. |
||
164 | * |
||
165 | * @param array $attributes |
||
166 | * @return bool |
||
167 | */ |
||
168 | public function update(array $attributes = []) |
||
172 | |||
173 | /** |
||
174 | * Delete a record. |
||
175 | * |
||
176 | * @param EloquentModel $entry |
||
177 | * @return bool |
||
178 | */ |
||
179 | public function delete(EloquentModel $entry) |
||
183 | |||
184 | /** |
||
185 | * Force delete a record. |
||
186 | * |
||
187 | * @param EloquentModel $entry |
||
188 | * @return bool |
||
189 | */ |
||
190 | public function forceDelete(EloquentModel $entry) |
||
196 | |||
197 | /** |
||
198 | * Restore a trashed record. |
||
199 | * |
||
200 | * @param EloquentModel $entry |
||
201 | * @return bool |
||
202 | */ |
||
203 | public function restore(EloquentModel $entry) |
||
207 | |||
208 | /** |
||
209 | * Truncate the entries. |
||
210 | * |
||
211 | * @return $this |
||
212 | */ |
||
213 | public function truncate() |
||
236 | |||
237 | /** |
||
238 | * Set the model. |
||
239 | * |
||
240 | * @param EloquentModel $model |
||
241 | * @return $this |
||
242 | */ |
||
243 | public function setModel(EloquentModel $model) |
||
249 | |||
250 | /** |
||
251 | * Get the model. |
||
252 | * |
||
253 | * @return EloquentModel |
||
254 | */ |
||
255 | public function getModel() |
||
259 | |||
260 | /** |
||
261 | * Pipe non-existing calls through hooks. |
||
262 | * |
||
263 | * @param $method |
||
264 | * @param $parameters |
||
265 | * @return mixed|null |
||
266 | */ |
||
267 | public function __call($method, $parameters) |
||
275 | } |
||
276 |
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: