File tree Expand file tree Collapse file tree 4 files changed +34
-7
lines changed Expand file tree Collapse file tree 4 files changed +34
-7
lines changed Original file line number Diff line number Diff line change @@ -244,10 +244,10 @@ public function repository(string $class): Repository
244244 *
245245 * @phpstan-ignore argument.type
246246 */
247- return $ this ->repositories [$ class ] = $ this -> app -> make ( $ repositoryClass, [
248- ' concise ' => $ this ,
249- ' mapper ' => $ mapper ,
250- ' connection ' => $ this ->databases ->connection ($ mapper ->connection ()),
251- ] );
247+ return $ this ->repositories [$ class ] = new $ repositoryClass(
248+ concise : $ this ,
249+ mapper : $ mapper ,
250+ connection: $ this ->databases ->connection ($ mapper ->connection ()),
251+ );
252252 }
253253}
Original file line number Diff line number Diff line change 22
33namespace Articulate \Concise \Contracts ;
44
5+ use Articulate \Concise \Concise ;
6+ use Illuminate \Database \Connection ;
7+
58/**
69 * @template EntityType of object
710 */
811interface Repository
912{
10-
13+ /**
14+ * Create a new repository instance.
15+ *
16+ * @param \Articulate\Concise\Concise $concise
17+ * @param \Articulate\Concise\Contracts\EntityMapper<EntityType> $mapper
18+ * @param \Illuminate\Database\Connection $connection
19+ */
20+ public function __construct (
21+ Concise $ concise ,
22+ EntityMapper $ mapper ,
23+ Connection $ connection
24+ );
1125}
Original file line number Diff line number Diff line change 33
44namespace Articulate \Concise \Support ;
55
6+ use App \Models \User ;
67use Articulate \Concise \Concise ;
78use Articulate \Concise \Contracts \EntityMapper ;
89use Articulate \Concise \Contracts \Repository ;
@@ -40,7 +41,7 @@ abstract class BaseRepository implements Repository
4041 public function __construct (
4142 Concise $ concise ,
4243 EntityMapper $ mapper ,
43- Connection $ connection
44+ Connection $ connection,
4445 )
4546 {
4647 $ this ->concise = $ concise ;
Original file line number Diff line number Diff line change 1010use App \Mappers \Components \TimestampsMapper ;
1111use App \Mappers \Entities \UserMapper ;
1212use App \Providers \MapperServiceProvider ;
13+ use App \Repositories \UserRepository ;
1314use Articulate \Concise \Concise ;
1415use Articulate \Concise \ConciseServiceProvider ;
1516use PHPUnit \Framework \Attributes \Test ;
@@ -58,4 +59,15 @@ public function hasRegisteredMappersSuccessfully(): void
5859 $ this ->assertInstanceOf (AuthCredentialsMapper::class, $ componentMappers [AuthCredentials::class]);
5960 $ this ->assertInstanceOf (TimestampsMapper::class, $ componentMappers [Timestamps::class]);
6061 }
62+
63+ #[Test]
64+ public function bindsEntityRepositoriesCorrectly (): void
65+ {
66+ $ this ->assertTrue ($ this ->app ->providerIsLoaded (MapperServiceProvider::class));
67+
68+ $ concise = $ this ->app ->make (Concise::class);
69+
70+ $ this ->assertTrue ($ this ->app ->bound (UserRepository::class));
71+ $ this ->assertSame ($ this ->app ->make (UserRepository::class), $ concise ->repository (User::class));
72+ }
6173}
You can’t perform that action at this time.
0 commit comments