File tree Expand file tree Collapse file tree 4 files changed +26
-5
lines changed Expand file tree Collapse file tree 4 files changed +26
-5
lines changed Original file line number Diff line number Diff line change 5
5
6
6
use Articulate \Concise \Contracts \EntityMapper ;
7
7
use Articulate \Concise \Contracts \Repository ;
8
- use Closure ;
9
8
use Illuminate \Contracts \Foundation \Application ;
10
9
use Illuminate \Database \DatabaseManager ;
11
10
use InvalidArgumentException ;
@@ -226,8 +225,8 @@ public function repository(string $class): Repository
226
225
$ repository = $ this ->repositories [$ class ] ?? null ;
227
226
228
227
if ($ repository !== null ) {
229
- return $ repository ;
230
228
/** @phpstan-ignore return.type */
229
+ return $ repository ;
231
230
}
232
231
233
232
$ repositoryClass = $ mapper ->repository ();
Original file line number Diff line number Diff line change @@ -18,13 +18,22 @@ public function register(): void
18
18
$ this ->booted ($ this ->registerRepositories (...));
19
19
}
20
20
21
+ /**
22
+ * @param \Articulate\Concise\Concise $concise
23
+ *
24
+ * @return void
25
+ */
21
26
protected function registerRepositories (Concise $ concise ): void
22
27
{
23
- foreach ($ concise ->getEntityMappers () as $ mapper ) {
28
+ /**
29
+ * @var class-string $entity
30
+ * @var \Articulate\Concise\Contracts\EntityMapper<*> $mapper
31
+ */
32
+ foreach ($ concise ->getEntityMappers () as $ entity => $ mapper ) {
24
33
$ repo = $ mapper ->repository ();
25
34
26
35
if ($ repo !== null ) {
27
- $ this ->app ->bind ($ repo , fn () => $ concise ->repository ($ mapper -> getClass () ));
36
+ $ this ->app ->bind ($ repo , fn () => $ concise ->repository ($ entity ));
28
37
}
29
38
}
30
39
}
Original file line number Diff line number Diff line change @@ -107,6 +107,16 @@ protected function hydrate(?array $data): ?object
107
107
*/
108
108
protected function hydrateMany (Collection $ collection ): Collection
109
109
{
110
- return $ collection ->map (fn (array $ data ) => $ this ->hydrate ($ data ));
110
+ $ newCollection = new Collection ();
111
+
112
+ foreach ($ collection as $ data ) {
113
+ $ entity = $ this ->hydrate ($ data );
114
+
115
+ if ($ entity !== null ) {
116
+ $ newCollection ->push ($ entity );
117
+ }
118
+ }
119
+
120
+ return $ newCollection ;
111
121
}
112
122
}
Original file line number Diff line number Diff line change 8
8
9
9
abstract class MapperServiceProvider extends ServiceProvider
10
10
{
11
+ /**
12
+ * @var array<class-string, class-string<\Articulate\Concise\Contracts\EntityMapper<*>>>
13
+ */
11
14
protected array $ mappers = [];
12
15
13
16
public function register (): void
You can’t perform that action at this time.
0 commit comments