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 a trashed record by it's ID. |
||
46 | * |
||
47 | * @param $id |
||
48 | * @return null|EloquentModel |
||
49 | */ |
||
50 | public function findTrashed($id) |
||
58 | |||
59 | /** |
||
60 | * Create a new record. |
||
61 | * |
||
62 | * @param array $attributes |
||
63 | * @return EloquentModel |
||
64 | */ |
||
65 | public function create(array $attributes) |
||
69 | |||
70 | /** |
||
71 | * Return a new instance. |
||
72 | * |
||
73 | * @return EloquentModel |
||
74 | */ |
||
75 | public function newInstance() |
||
79 | |||
80 | /** |
||
81 | * Count all records. |
||
82 | * |
||
83 | * @return int |
||
84 | */ |
||
85 | public function count() |
||
89 | |||
90 | /** |
||
91 | * Return a paginated collection. |
||
92 | * |
||
93 | * @param array $parameters |
||
94 | * @return LengthAwarePaginator |
||
95 | */ |
||
96 | public function paginate(array $parameters = []) |
||
139 | |||
140 | /** |
||
141 | * Save a record. |
||
142 | * |
||
143 | * @param EloquentModel $entry |
||
144 | * @return bool |
||
145 | */ |
||
146 | public function save(EloquentModel $entry) |
||
150 | |||
151 | /** |
||
152 | * Update multiple records. |
||
153 | * |
||
154 | * @param array $attributes |
||
155 | * @return bool |
||
156 | */ |
||
157 | public function update(array $attributes = []) |
||
161 | |||
162 | /** |
||
163 | * Delete a record. |
||
164 | * |
||
165 | * @param EloquentModel $entry |
||
166 | * @return bool |
||
167 | */ |
||
168 | public function delete(EloquentModel $entry) |
||
172 | |||
173 | /** |
||
174 | * Force delete a record. |
||
175 | * |
||
176 | * @param EloquentModel $entry |
||
177 | * @return bool |
||
178 | */ |
||
179 | public function forceDelete(EloquentModel $entry) |
||
185 | |||
186 | /** |
||
187 | * Restore a trashed record. |
||
188 | * |
||
189 | * @param EloquentModel $entry |
||
190 | * @return bool |
||
191 | */ |
||
192 | public function restore(EloquentModel $entry) |
||
196 | |||
197 | /** |
||
198 | * Truncate the entries. |
||
199 | * |
||
200 | * @return $this |
||
201 | */ |
||
202 | public function truncate() |
||
225 | |||
226 | /** |
||
227 | * Set the model. |
||
228 | * |
||
229 | * @param EloquentModel $model |
||
230 | * @return $this |
||
231 | */ |
||
232 | public function setModel(EloquentModel $model) |
||
238 | |||
239 | /** |
||
240 | * Get the model. |
||
241 | * |
||
242 | * @return EloquentModel |
||
243 | */ |
||
244 | public function getModel() |
||
248 | |||
249 | /** |
||
250 | * Pipe non-existing calls through hooks. |
||
251 | * |
||
252 | * @param $method |
||
253 | * @param $parameters |
||
254 | * @return mixed|null |
||
255 | */ |
||
256 | public function __call($method, $parameters) |
||
264 | } |
||
265 |
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: