|
| 1 | +<?php |
| 2 | + |
| 3 | + |
| 4 | +namespace Changiz\DatabaseRepository; |
| 5 | + |
| 6 | + |
| 7 | +use Changiz\DatabaseRepository\Commands\MakeAllRepository; |
| 8 | +use Changiz\DatabaseRepository\Commands\MakeEntity; |
| 9 | +use Changiz\DatabaseRepository\Commands\MakeFactory; |
| 10 | +use Changiz\DatabaseRepository\Commands\MakeInterfaceRepository; |
| 11 | +use Changiz\DatabaseRepository\Commands\MakeMySqlRepository; |
| 12 | +use Changiz\DatabaseRepository\Commands\MakeRedisRepository; |
| 13 | +use Changiz\DatabaseRepository\Commands\MakeRepository; |
| 14 | +use Illuminate\Support\ServiceProvider; |
| 15 | + |
| 16 | +/** |
| 17 | + * Laravel service provider for DatabaseRepositor. |
| 18 | + * |
| 19 | + */ |
| 20 | +class DatabaseRepositoryServiceProvider extends ServiceProvider |
| 21 | +{ |
| 22 | + /** |
| 23 | + * The package configuration file. |
| 24 | + */ |
| 25 | + const CONFIG_FILE = 'repository.php'; |
| 26 | + |
| 27 | + /** |
| 28 | + * Bootstrap the application events. |
| 29 | + */ |
| 30 | + public function boot() |
| 31 | + { |
| 32 | + $this->publishes([ |
| 33 | + __DIR__ . '/Config/' . self::CONFIG_FILE => config_path(self::CONFIG_FILE), |
| 34 | + ], 'config'); |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * Register the service provider. |
| 39 | + */ |
| 40 | + public function register() |
| 41 | + { |
| 42 | + $this->registerCommand(); |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * Register custom commands. |
| 47 | + */ |
| 48 | + private function registerCommand() |
| 49 | + { |
| 50 | + $this->app->singleton('command.make-all-repository', function () { |
| 51 | + return new MakeAllRepository(); |
| 52 | + }); |
| 53 | + |
| 54 | + $this->app->singleton('command.make-entity', function () { |
| 55 | + return new MakeEntity(); |
| 56 | + }); |
| 57 | + |
| 58 | + $this->app->singleton('command.make-factory', function () { |
| 59 | + return new MakeFactory(); |
| 60 | + }); |
| 61 | + |
| 62 | + $this->app->singleton('command.make-interface-repository', function () { |
| 63 | + return new MakeInterfaceRepository(); |
| 64 | + }); |
| 65 | + |
| 66 | + $this->app->singleton('command.make-mysql-repository', function () { |
| 67 | + return new MakeMySqlRepository(); |
| 68 | + }); |
| 69 | + |
| 70 | + $this->app->singleton('command.make-redis-repository', function () { |
| 71 | + return new MakeRedisRepository(); |
| 72 | + }); |
| 73 | + |
| 74 | + $this->app->singleton('command.make-repository', function () { |
| 75 | + return new MakeRepository(); |
| 76 | + }); |
| 77 | + |
| 78 | + $this->app->singleton('command.make-resource', function () { |
| 79 | + return new MakeResource(); |
| 80 | + }); |
| 81 | + |
| 82 | + $this->commands([ |
| 83 | + 'command:make-all-repository', |
| 84 | + 'command:make-entity', |
| 85 | + 'command:make-factory', |
| 86 | + 'command:make-interface-repository', |
| 87 | + 'command:make-mysql-repository', |
| 88 | + 'command:make-redis-repository', |
| 89 | + 'command:make-repository', |
| 90 | + 'command:make-resource' |
| 91 | + ]); |
| 92 | + } |
| 93 | + |
| 94 | +} |
0 commit comments