You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PaymentServiceProvider.php 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace MirfalahTech\Laravel\Payment;
  3. use Illuminate\Contracts\Config\Repository;
  4. use Illuminate\Contracts\Container\BindingResolutionException;
  5. use Illuminate\Contracts\Foundation\Application;
  6. use Illuminate\Support\ServiceProvider;
  7. use MirfalahTech\Laravel\Payment\Manager\PaymentManager;
  8. class PaymentServiceProvider extends ServiceProvider
  9. {
  10. /**
  11. * @throws BindingResolutionException
  12. */
  13. public function boot()
  14. {
  15. $config_path = realpath(__DIR__ . '/../config/payment.php');
  16. /** @var Repository $config */
  17. $config = $this->app->make('config');
  18. /** @noinspection PhpIncludeInspection */
  19. $config->set('payment', array_merge(
  20. require $config_path,
  21. $config->get('payment', [])
  22. ));
  23. $this->app->singleton('payment', function (Application $app) use ($config) {
  24. return new PaymentManager($app, $config->get('payment.default'));
  25. });
  26. $this->app->alias('payment', PaymentManager::class);
  27. $this->publishes([
  28. $config_path => $this->app->configPath('payment.php')
  29. ], 'config');
  30. }
  31. }