1919 */
2020class DatabaseRepositoryServiceProvider extends ServiceProvider
2121{
22+ private $ baseModelStubPath ;
23+
24+ public function __construct ($ app )
25+ {
26+ parent ::__construct ($ app );
27+
28+ $ this ->baseModelStubPath = __DIR__ . '/../stubs/Models/PHP ' .env ('REPOSITORY_PHP_VERSION ' , '8.0 ' );
29+ }
30+
2231 /**
2332 * Register the service provider.
2433 */
@@ -42,9 +51,66 @@ public function offerPublishing(): void
4251 $ this ->publishes ([
4352 __DIR__ . '/../stubs/PHP ' .env ('REPOSITORY_PHP_VERSION ' , '8.0 ' ) => $ this ->app ->basePath ('stubs ' ),
4453 ], 'repository-stubs ' );
54+
55+ $ this ->publishEnums ();
56+ $ this ->publishEntities ();
57+ $ this ->publishFactories ();
58+ $ this ->publishResources ();
59+ $ this ->publishRepositories ();
4560 }
4661 }
4762
63+ private function publishEnums (): void
64+ {
65+ $ this ->publishes ([
66+ $ this ->baseModelStubPath .'/Enums/Enum.stub ' => $ this ->app ->basePath ('app/Models/Enums/Enum.php ' ),
67+ ], ['repository-base-classes ' , 'repository-base-enum ' ]);
68+
69+ $ this ->publishes ([
70+ $ this ->baseModelStubPath .'/Enums/GriewFilterOperator.stub ' => $ this ->app ->basePath ('app/Models/Enums/GriewFilterOperator.php ' ),
71+ ], ['repository-base-classes ' , 'repository-griew-enums ' ]);
72+ }
73+
74+ private function publishEntities (): void
75+ {
76+ $ this ->publishes ([
77+ $ this ->baseModelStubPath .'/Entity/Entity.stub ' => $ this ->app ->basePath ('app/Models/Entities/Entity.php ' ),
78+ ], ['repository-base-classes ' , 'repository-base-entity ' ]);
79+ }
80+
81+ private function publishFactories (): void
82+ {
83+ $ this ->publishes ([
84+ $ this ->baseModelStubPath .'/Factory/Factory.stub ' => $ this ->app ->basePath ('app/Models/Factories/Factory.php ' ),
85+ ], ['repository-base-classes ' , 'repository-base-factory ' ]);
86+
87+ $ this ->publishes ([
88+ $ this ->baseModelStubPath .'/Factory/IFactory.stub ' => $ this ->app ->basePath ('app/Models/Factories/IFactory.php ' ),
89+ ], ['repository-base-classes ' , 'repository-base-factory ' ]);
90+ }
91+
92+ private function publishResources (): void
93+ {
94+ $ this ->publishes ([
95+ $ this ->baseModelStubPath .'/Resource/Resource.stub ' => $ this ->app ->basePath ('app/Models/Resources/Resource.php ' ),
96+ ], ['repository-base-classes ' , 'repository-base-resource ' ]);
97+
98+ $ this ->publishes ([
99+ $ this ->baseModelStubPath .'/Resource/IResource.stub ' => $ this ->app ->basePath ('app/Models/Resources/IResource.php ' ),
100+ ], ['repository-base-classes ' , 'repository-base-resource ' ]);
101+ }
102+
103+ private function publishRepositories (): void
104+ {
105+ $ this ->publishes ([
106+ $ this ->baseModelStubPath .'/Repository/MySqlRepository.stub ' => $ this ->app ->basePath ('app/Models/Repositories/MySqlRepository.php ' ),
107+ ], ['repository-base-classes ' , 'repository-base-mysql-repository ' ]);
108+
109+ $ this ->publishes ([
110+ $ this ->baseModelStubPath .'/Repository/RedisRepository.stub ' => $ this ->app ->basePath ('app/Models/Repositories/RedisRepository.php ' ),
111+ ], ['repository-base-classes ' , 'repository-base-redis-repository ' ]);
112+ }
113+
48114 /**
49115 * Register custom commands.
50116 */
0 commit comments