| 1 | <?php |
||
| 6 | |||
| 7 | class YourMembershipServiceProvider extends ServiceProvider |
||
| 8 | { |
||
| 9 | |||
| 10 | private $packageName = 'yourmembership'; |
||
| 11 | private $packageConfigPath = __DIR__.'/config/yourmembership.php'; |
||
| 12 | /** |
||
| 13 | * Indicates if loading of the provider is deferred. |
||
| 14 | * |
||
| 15 | * @var bool |
||
| 16 | */ |
||
| 17 | protected $defer = true; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Register the service provider. |
||
| 21 | * |
||
| 22 | * @return void |
||
| 23 | */ |
||
| 24 | public function register() |
||
| 25 | { |
||
| 26 | $this->mergeConfigFrom( |
||
| 27 | $this->packageConfigPath, $this->packageName |
||
| 28 | ); |
||
| 29 | |||
| 30 | $this->app->register(YourMembershipClient::class, function($app, $parameters) { |
||
| 31 | |||
| 32 | $guzzleClient = new \GuzzleHttp\Client($app['config']['yourmembership']['guzzle-client']); |
||
| 33 | |||
| 34 | return new YourMembershipClient($guzzleClient, $parameters[0], $parameters[1]) |
||
| 35 | }); |
||
|
|
|||
| 36 | } |
||
| 37 | |||
| 38 | public function boot() |
||
| 39 | { |
||
| 40 | $this->publishes([ |
||
| 41 | $this->packageConfigPath => config_path('yourmembership.php'), |
||
| 42 | ]); |
||
| 56 |