Skip to content

Commit bd999b1

Browse files
committed
Minor fix on type-hinted return
1 parent fc180db commit bd999b1

File tree

4 files changed

+22
-24
lines changed

4 files changed

+22
-24
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ Laravel Repository design pattern package that comes with caching features
88
</p>
99

1010
## Overview
11-
Laravel package that revolves around Repository design pattern to encapsulate database-related functions and reuse in other classes.
11+
Laravel package that revolves around Repository design pattern to encapsulate database-related functions, making our application more flexible and classes are reusable.
1212
Comes with normal repository features and caching features as well.

src/Commands/stubs/repository.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class %modelName%Repository extends BaseRepository implements %interface%
1212
*
1313
* @return string
1414
*/
15-
public function model()
15+
public function model(): string
1616
{
1717
return %modelName%::class;
1818
}

src/Contracts/RepositoryInterface.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
namespace CodeOfDigital\CacheRepository\Contracts;
44

55
use Closure;
6-
use Illuminate\Database\Eloquent\Builder;
76
use Illuminate\Database\Eloquent\Collection;
8-
use Illuminate\Database\Eloquent\Model;
97

108
interface RepositoryInterface
119
{
@@ -21,19 +19,19 @@ public function count(array $where = [], $columns = '*'): int;
2119

2220
public function get($columns = ['*']): mixed;
2321

24-
public function first($columns = ['*']): Model|Builder;
22+
public function first($columns = ['*']): mixed;
2523

26-
public function firstOrNew(array $attributes = []): Model|Builder;
24+
public function firstOrNew(array $attributes = []): mixed;
2725

28-
public function firstOrCreate(array $attributes = []): Model|Builder;
26+
public function firstOrCreate(array $attributes = []): mixed;
2927

3028
public function limit($limit, $columns = ['*']): mixed;
3129

3230
public function paginate($limit = null, $columns = ['*']): mixed;
3331

3432
public function simplePaginate($limit = null, $columns = ['*']): mixed;
3533

36-
public function find(int $id, $columns = ['*']): Model|Builder;
34+
public function find(int $id, $columns = ['*']): mixed;
3735

3836
public function findByField(string $field, $value, $columns = ['*']): Collection|array;
3937

@@ -45,19 +43,19 @@ public function findWhereNotIn($field, array $values, $columns = ['*']): Collect
4543

4644
public function findWhereBetween($field, array $values, $columns = ['*']): Collection|array;
4745

48-
public function create(array $attributes): Model;
46+
public function create(array $attributes): mixed;
4947

50-
public function update(array $attributes, int $id): Model;
48+
public function update(array $attributes, int $id): mixed;
5149

52-
public function updateOrCreate(array $attributes, array $values = []): Model|Builder;
50+
public function updateOrCreate(array $attributes, array $values = []): mixed;
5351

54-
public function delete(int $id): Model;
52+
public function delete(int $id): mixed;
5553

5654
public function deleteWhere(array $where): ?bool;
5755

58-
public function forceDelete(int $id): Model;
56+
public function forceDelete(int $id): mixed;
5957

60-
public function restore(int $id): Model;
58+
public function restore(int $id): mixed;
6159

6260
public function has($relation): static;
6361

src/Eloquent/BaseRepository.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function get($columns = ['*']): mixed
113113
return $this->all($columns);
114114
}
115115

116-
public function first($columns = ['*']): Model|Builder
116+
public function first($columns = ['*']): mixed
117117
{
118118
$this->applyScope();
119119

@@ -124,7 +124,7 @@ public function first($columns = ['*']): Model|Builder
124124
return $result;
125125
}
126126

127-
public function firstOrNew(array $attributes = []): Model|Builder
127+
public function firstOrNew(array $attributes = []): mixed
128128
{
129129
$this->applyScope();
130130

@@ -135,7 +135,7 @@ public function firstOrNew(array $attributes = []): Model|Builder
135135
return $model;
136136
}
137137

138-
public function firstOrCreate(array $attributes = []): Model|Builder
138+
public function firstOrCreate(array $attributes = []): mixed
139139
{
140140
$this->applyScope();
141141

@@ -172,7 +172,7 @@ public function simplePaginate($limit = null, $columns = ['*']): mixed
172172
return $this->paginate($limit, $columns, "simplePaginate");
173173
}
174174

175-
public function find(int $id, $columns = ['*']): Model|Builder
175+
public function find(int $id, $columns = ['*']): mixed
176176
{
177177
$this->applyScope();
178178
$model = $this->model->findOrFail($id, $columns);
@@ -227,7 +227,7 @@ public function findWhereBetween($field, array $values, $columns = ['*']): Colle
227227
return $model;
228228
}
229229

230-
public function create(array $attributes): Model
230+
public function create(array $attributes): mixed
231231
{
232232
$model = $this->model->newInstance($attributes);
233233
$model->save();
@@ -238,7 +238,7 @@ public function create(array $attributes): Model
238238
return $model;
239239
}
240240

241-
public function update(array $attributes, int $id): Model
241+
public function update(array $attributes, int $id): mixed
242242
{
243243
$this->applyScope();
244244

@@ -251,7 +251,7 @@ public function update(array $attributes, int $id): Model
251251
return $model;
252252
}
253253

254-
public function updateOrCreate(array $attributes, array $values = []): Model|Builder
254+
public function updateOrCreate(array $attributes, array $values = []): mixed
255255
{
256256
$this->applyScope();
257257

@@ -263,7 +263,7 @@ public function updateOrCreate(array $attributes, array $values = []): Model|Bui
263263
return $model;
264264
}
265265

266-
public function delete(int $id): Model
266+
public function delete(int $id): mixed
267267
{
268268
return $this->manageDeletes($id, 'delete');
269269
}
@@ -282,12 +282,12 @@ public function deleteWhere(array $where): ?bool
282282
return $deleted;
283283
}
284284

285-
public function forceDelete(int $id): Model
285+
public function forceDelete(int $id): mixed
286286
{
287287
return $this->manageDeletes($id, 'forceDelete');
288288
}
289289

290-
public function restore(int $id): Model
290+
public function restore(int $id): mixed
291291
{
292292
return $this->manageDeletes($id, 'restore');
293293
}

0 commit comments

Comments
 (0)