2
2
3
3
namespace Fuzz \MagicBox \Contracts ;
4
4
5
- use Fuzz \MagicBox \EloquentRepository ;
5
+ use Closure ;
6
+ use Illuminate \Database \Eloquent \Collection ;
6
7
use Illuminate \Database \Eloquent \Model ;
8
+ use Illuminate \Contracts \Pagination \Paginator ;
7
9
8
10
interface Repository
9
11
{
10
12
/**
11
13
* Set the model for an instance of this resource controller.
12
14
*
13
15
* @param string $model_class
14
- * @return static
16
+ * @return \Fuzz\MagicBox\Contracts\Repository
15
17
*/
16
- public function setModelClass ($ model_class );
18
+ public function setModelClass ($ model_class ): Repository ;
17
19
18
20
/**
19
21
* Get the model class.
20
22
*
21
23
* @return string
22
24
*/
23
- public function getModelClass ();
25
+ public function getModelClass (): string ;
24
26
25
27
/**
26
28
* Set input manually.
27
29
*
28
30
* @param array $input
29
- * @return static
31
+ * @return \Fuzz\MagicBox\Contracts\Repository
30
32
*/
31
- public function setInput (array $ input );
33
+ public function setInput (array $ input ): Repository ;
32
34
33
35
/**
34
36
* Get input.
35
37
*
36
38
* @return array
37
39
*/
38
- public function getInput ();
40
+ public function getInput (): array ;
39
41
40
42
/**
41
43
* Get the PK name
@@ -55,60 +57,69 @@ public function exists(): bool;
55
57
* Set eager load manually.
56
58
*
57
59
* @param array $eager_loads
58
- * @return static
60
+ * @return \Fuzz\MagicBox\Contracts\Repository
59
61
*/
60
- public function setEagerLoads (array $ eager_loads );
62
+ public function setEagerLoads (array $ eager_loads ): Repository ;
61
63
62
64
/**
63
65
* Get eager loads.
64
66
*
65
67
* @return array
66
68
*/
67
- public function getEagerLoads ();
69
+ public function getEagerLoads (): array ;
68
70
69
71
/**
70
72
* Set filters manually.
71
73
*
72
74
* @param array $filters
73
- * @return static
75
+ * @return \Fuzz\MagicBox\Contracts\Repository
74
76
*/
75
- public function setFilters (array $ filters );
77
+ public function setFilters (array $ filters ): Repository ;
76
78
77
79
/**
78
80
* Get filters.
79
81
*
80
82
* @return array
81
83
*/
82
- public function getFilters ();
84
+ public function getFilters (): array ;
85
+
86
+ /**
87
+ * Add a single modifier
88
+ *
89
+ * @param \Closure $modifier
90
+ *
91
+ * @return \Fuzz\MagicBox\Contracts\Repository
92
+ */
93
+ public function addModifier (Closure $ modifier ): Repository ;
83
94
84
95
/**
85
96
* Set modifiers.
86
97
*
87
98
* @param array $modifiers
88
- * @return static
99
+ * @return \Fuzz\MagicBox\Contracts\Repository
89
100
*/
90
- public function setModifiers (array $ modifiers );
101
+ public function setModifiers (array $ modifiers ): Repository ;
91
102
92
103
/**
93
104
* Get modifiers.
94
105
*
95
106
* @return array
96
107
*/
97
- public function getModifiers ();
108
+ public function getModifiers (): array ;
98
109
99
110
/**
100
111
* Return a model's fields.
101
112
*
102
113
* @param \Illuminate\Database\Eloquent\Model $instance
103
114
* @return array
104
115
*/
105
- public static function getFields (Model $ instance );
116
+ public static function getFields (Model $ instance ): array ;
106
117
107
118
/**
108
119
* Find an instance of a model by ID.
109
120
*
110
121
* @param int $id
111
- * @return \Illuminate\Database\Eloquent\Model
122
+ * @return \Illuminate\Database\Eloquent\Model|null
112
123
*/
113
124
public function find ($ id );
114
125
@@ -118,43 +129,43 @@ public function find($id);
118
129
* @param int $id
119
130
* @return \Illuminate\Database\Eloquent\Model
120
131
*/
121
- public function findOrFail ($ id );
132
+ public function findOrFail ($ id ): Model ;
122
133
123
134
/**
124
135
* Get all elements against the base query.
125
136
*
126
137
* @return \Illuminate\Database\Eloquent\Collection
127
138
*/
128
- public function all ();
139
+ public function all (): Collection ;
129
140
130
141
/**
131
142
* Return paginated response.
132
143
*
133
144
* @param int $per_page
134
- * @return \Illuminate\Pagination\Paginator
145
+ * @return \Illuminate\Contracts\ Pagination\Paginator
135
146
*/
136
- public function paginate ($ per_page );
147
+ public function paginate ($ per_page ): Paginator ;
137
148
138
149
/**
139
150
* Count all elements against the base query.
140
151
*
141
152
* @return int
142
153
*/
143
- public function count ();
154
+ public function count (): int ;
144
155
145
156
/**
146
157
* Determine if the base query returns a nonzero count.
147
158
*
148
159
* @return bool
149
160
*/
150
- public function hasAny ();
161
+ public function hasAny (): bool ;
151
162
152
163
/**
153
164
* Get a random value.
154
165
*
155
166
* @return \Illuminate\Database\Eloquent\Model
156
167
*/
157
- public function random ();
168
+ public function random (): Model ;
158
169
159
170
/**
160
171
* Get the primary key from input.
@@ -168,44 +179,44 @@ public function getInputId();
168
179
*
169
180
* @return \Illuminate\Database\Eloquent\Model
170
181
*/
171
- public function create ();
182
+ public function create (): Model ;
172
183
173
184
/**
174
185
* Read a model.
175
186
*
176
187
* @return \Illuminate\Database\Eloquent\Model
177
188
*/
178
- public function read ();
189
+ public function read (): Model ;
179
190
180
191
/**
181
192
* Update a model.
182
193
*
183
194
* @return \Illuminate\Database\Eloquent\Model
184
195
*/
185
- public function update ();
196
+ public function update (): Model ;
186
197
187
198
/**
188
199
* Update a model.
189
200
*
190
201
* @return boolean
191
202
*/
192
- public function delete ();
203
+ public function delete (): bool ;
193
204
194
205
/**
195
206
* Save a model, regardless of whether or not it is "new".
196
207
*
197
208
* @return \Illuminate\Database\Eloquent\Model
198
209
*/
199
- public function save ();
210
+ public function save (): Model ;
200
211
201
212
/**
202
213
* Set the fillable array
203
214
*
204
215
* @param array $fillable
205
216
*
206
- * @return \Fuzz\MagicBox\EloquentRepository
217
+ * @return \Fuzz\MagicBox\Contracts\Repository
207
218
*/
208
- public function setFillable (array $ fillable ): EloquentRepository ;
219
+ public function setFillable (array $ fillable ): Repository ;
209
220
210
221
/**
211
222
* Get the fillable attributes
@@ -221,36 +232,36 @@ public function getFillable(bool $assoc = false): array;
221
232
*
222
233
* @param string $fillable
223
234
*
224
- * @return \Fuzz\MagicBox\EloquentRepository
235
+ * @return \Fuzz\MagicBox\Contracts\Repository
225
236
*/
226
- public function addFillable (string $ fillable ): EloquentRepository ;
237
+ public function addFillable (string $ fillable ): Repository ;
227
238
228
239
/**
229
240
* Add many fillable fields
230
241
*
231
242
* @param array $fillable
232
243
*
233
- * @return \Fuzz\MagicBox\EloquentRepository
244
+ * @return \Fuzz\MagicBox\Contracts\Repository
234
245
*/
235
- public function addManyFillable (array $ fillable ): EloquentRepository ;
246
+ public function addManyFillable (array $ fillable ): Repository ;
236
247
237
248
/**
238
249
* Remove a fillable attribute
239
250
*
240
251
* @param string $fillable
241
252
*
242
- * @return \Fuzz\MagicBox\EloquentRepository
253
+ * @return \Fuzz\MagicBox\Contracts\Repository
243
254
*/
244
- public function removeFillable (string $ fillable ): EloquentRepository ;
255
+ public function removeFillable (string $ fillable ): Repository ;
245
256
246
257
/**
247
258
* Remove many fillable fields
248
259
*
249
260
* @param array $fillable
250
261
*
251
- * @return \Fuzz\MagicBox\EloquentRepository
262
+ * @return \Fuzz\MagicBox\Contracts\Repository
252
263
*/
253
- public function removeManyFillable (array $ fillable ): EloquentRepository ;
264
+ public function removeManyFillable (array $ fillable ): Repository ;
254
265
255
266
/**
256
267
* Determine whether a given key is fillable
@@ -266,9 +277,9 @@ public function isFillable(string $key): bool;
266
277
*
267
278
* @param array $includable
268
279
*
269
- * @return \Fuzz\MagicBox\EloquentRepository
280
+ * @return \Fuzz\MagicBox\Contracts\Repository
270
281
*/
271
- public function setIncludable (array $ includable ): EloquentRepository ;
282
+ public function setIncludable (array $ includable ): Repository ;
272
283
273
284
/**
274
285
* Get the includable relationships
@@ -284,36 +295,36 @@ public function getIncludable(bool $assoc = false): array;
284
295
*
285
296
* @param string $includable
286
297
*
287
- * @return \Fuzz\MagicBox\EloquentRepository
298
+ * @return \Fuzz\MagicBox\Contracts\Repository
288
299
*/
289
- public function addIncludable (string $ includable ): EloquentRepository ;
300
+ public function addIncludable (string $ includable ): Repository ;
290
301
291
302
/**
292
303
* Add many includable fields
293
304
*
294
305
* @param array $includable
295
306
*
296
- * @return \Fuzz\MagicBox\EloquentRepository
307
+ * @return \Fuzz\MagicBox\Contracts\Repository
297
308
*/
298
- public function addManyIncludable (array $ includable ): EloquentRepository ;
309
+ public function addManyIncludable (array $ includable ): Repository ;
299
310
300
311
/**
301
312
* Remove an includable relationship
302
313
*
303
314
* @param string $includable
304
315
*
305
- * @return \Fuzz\MagicBox\EloquentRepository
316
+ * @return \Fuzz\MagicBox\Contracts\Repository
306
317
*/
307
- public function removeIncludable (string $ includable ): EloquentRepository ;
318
+ public function removeIncludable (string $ includable ): Repository ;
308
319
309
320
/**
310
321
* Remove many includable relationships
311
322
*
312
323
* @param array $includable
313
324
*
314
- * @return \Fuzz\MagicBox\EloquentRepository
325
+ * @return \Fuzz\MagicBox\Contracts\Repository
315
326
*/
316
- public function removeManyIncludable (array $ includable ): EloquentRepository ;
327
+ public function removeManyIncludable (array $ includable ): Repository ;
317
328
318
329
/**
319
330
* Determine whether a given key is includable
@@ -329,9 +340,9 @@ public function isIncludable(string $key): bool;
329
340
*
330
341
* @param array $filterable
331
342
*
332
- * @return \Fuzz\MagicBox\EloquentRepository
343
+ * @return \Fuzz\MagicBox\Contracts\Repository
333
344
*/
334
- public function setFilterable (array $ filterable ): EloquentRepository ;
345
+ public function setFilterable (array $ filterable ): Repository ;
335
346
336
347
/**
337
348
* Get the filterable fields
@@ -347,36 +358,36 @@ public function getFilterable(bool $assoc = false): array;
347
358
*
348
359
* @param string $filterable
349
360
*
350
- * @return \Fuzz\MagicBox\EloquentRepository
361
+ * @return \Fuzz\MagicBox\Contracts\Repository
351
362
*/
352
- public function addFilterable (string $ filterable ): EloquentRepository ;
363
+ public function addFilterable (string $ filterable ): Repository ;
353
364
354
365
/**
355
366
* Add many filterable fields
356
367
*
357
368
* @param array $filterable
358
369
*
359
- * @return \Fuzz\MagicBox\EloquentRepository
370
+ * @return \Fuzz\MagicBox\Contracts\Repository
360
371
*/
361
- public function addManyFilterable (array $ filterable ): EloquentRepository ;
372
+ public function addManyFilterable (array $ filterable ): Repository ;
362
373
363
374
/**
364
375
* Remove a filterable field
365
376
*
366
377
* @param string $filterable
367
378
*
368
- * @return \Fuzz\MagicBox\EloquentRepository
379
+ * @return \Fuzz\MagicBox\Contracts\Repository
369
380
*/
370
- public function removeFilterable (string $ filterable ): EloquentRepository ;
381
+ public function removeFilterable (string $ filterable ): Repository ;
371
382
372
383
/**
373
384
* Remove many filterable fields
374
385
*
375
386
* @param array $filterable
376
387
*
377
- * @return \Fuzz\MagicBox\EloquentRepository
388
+ * @return \Fuzz\MagicBox\Contracts\Repository
378
389
*/
379
- public function removeManyFilterable (array $ filterable ): EloquentRepository ;
390
+ public function removeManyFilterable (array $ filterable ): Repository ;
380
391
381
392
/**
382
393
* Determine whether a given key is filterable
0 commit comments