|
3 | 3 | namespace PPSpaces\Repositories; |
4 | 4 |
|
5 | 5 | use ReflectionClass; |
6 | | -use JsonSerializable; |
7 | 6 |
|
8 | 7 | use Illuminate\Container\Container as App; |
9 | 8 |
|
10 | 9 | use Illuminate\Database\Eloquent\Model; |
11 | 10 | use Illuminate\Contracts\Routing\UrlRoutable; |
12 | 11 |
|
13 | 12 | use PPSpaces\Exceptions\RepositoryException; |
| 13 | +use PPSpaces\Repositories\RepositoryCollection; |
14 | 14 | use PPSpaces\Contracts\Repository as RepositoryContract; |
15 | 15 |
|
16 | | -abstract class Repository implements RepositoryContract, JsonSerializable, UrlRoutable { |
| 16 | +abstract class Repository implements RepositoryContract, UrlRoutable |
| 17 | +{ |
17 | 18 |
|
18 | 19 | /** |
19 | 20 | * The application instance being facaded. |
@@ -68,7 +69,7 @@ public function __construct(App $app) { |
68 | 69 | * @param \Illuminate\Database\Query\Builder $query |
69 | 70 | * @return void |
70 | 71 | */ |
71 | | - public function before($query) {} |
| 72 | + abstract public function before($query); |
72 | 73 |
|
73 | 74 | /** |
74 | 75 | * Get all of the models from the database. |
@@ -138,17 +139,15 @@ public function delete($id) { |
138 | 139 | * @param \Illuminate\Support\Collection|array|int $ids |
139 | 140 | * @return int |
140 | 141 | */ |
141 | | - public static function destroy($ids) { |
142 | | - // |
143 | | - } |
| 142 | + abstract static function destroy($ids); |
144 | 143 |
|
145 | 144 | /** |
146 | 145 | * Specify Model class name |
147 | 146 | * |
148 | 147 | * @return string |
149 | 148 | */ |
150 | 149 | public function model() { |
151 | | - return $this->model; |
| 150 | + return $this->resolved; |
152 | 151 | } |
153 | 152 |
|
154 | 153 | /** |
@@ -205,33 +204,17 @@ public function resolveRouteBinding($value) |
205 | 204 | return $this; |
206 | 205 | } |
207 | 206 |
|
208 | | - /** |
209 | | - * Convert the object into something JSON serializable. |
210 | | - * |
211 | | - * @return array |
212 | | - */ |
213 | | - public function jsonSerialize() |
214 | | - { |
215 | | - return $this->resolved->toArray(); |
216 | | - } |
217 | | - |
218 | | - /** |
219 | | - * Convert the model instance to an array. |
220 | | - * |
221 | | - * @return array |
222 | | - */ |
223 | | - public function toArray() |
224 | | - { |
225 | | - return $this->resolved->toArray(); |
226 | | - } |
227 | | - |
228 | 207 | /** |
229 | 208 | * Convert the model to its string representation. |
230 | 209 | * |
231 | 210 | * @return string |
232 | 211 | */ |
233 | 212 | public function __toString() |
234 | 213 | { |
235 | | - return $this->resolved->toJson(); |
| 214 | + if (isset($this->resolved)) { |
| 215 | + return $this->resolved->toJson(); |
| 216 | + } |
| 217 | + |
| 218 | + return null; |
236 | 219 | } |
237 | 220 | } |
0 commit comments