|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace GoCardlessPayment; |
|
4
|
|
|
|
|
5
|
|
|
use GoCardlessPayment\Console\Commands\ImportMandate; |
|
6
|
|
|
use GoCardlessPayment\Contracts\LocalCustomerRepository; |
|
7
|
|
|
use GoCardlessPayment\Repositories\LocalCustomerEloquentRepository; |
|
8
|
|
|
use Illuminate\Contracts\Foundation\Application; |
|
9
|
|
|
|
|
10
|
|
|
class ServiceProvider extends \Illuminate\Support\ServiceProvider |
|
11
|
|
|
{ |
|
12
|
12 |
|
public function boot() |
|
13
|
|
|
{ |
|
14
|
12 |
|
$this->registerRoutes(); |
|
15
|
|
|
|
|
16
|
12 |
|
if ($this->app->runningInConsole()) { |
|
17
|
12 |
|
$this->publishes([ |
|
18
|
12 |
|
__DIR__.'/../config/gocardless-payment.php' => config_path('gocardless-payment.php'), |
|
19
|
12 |
|
], 'config'); |
|
20
|
|
|
|
|
21
|
12 |
|
$this->publishes([ |
|
22
|
12 |
|
__DIR__.'/../database/migrations' => $this->app->databasePath('migrations'), |
|
23
|
12 |
|
], 'migrations'); |
|
24
|
|
|
|
|
25
|
12 |
|
$this->registerMigrations(); |
|
26
|
|
|
|
|
27
|
12 |
|
$this->commands([ |
|
28
|
12 |
|
ImportMandate::class, |
|
29
|
12 |
|
]); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
12 |
|
public function register() |
|
35
|
|
|
{ |
|
36
|
12 |
|
$this->mergeConfigFrom(__DIR__.'/../config/gocardless-payment.php', 'gocardless-payment'); |
|
37
|
|
|
|
|
38
|
12 |
|
$this->app->singletonIf(LocalCustomerRepository::class, function (Application $app) { |
|
|
|
|
|
|
39
|
8 |
|
return new LocalCustomerEloquentRepository( |
|
40
|
8 |
|
config('gocardless-payment.local_customer_repositories.eloquent.model'), |
|
41
|
8 |
|
config('gocardless-payment.local_customer_repositories.eloquent.key'), |
|
42
|
8 |
|
); |
|
43
|
12 |
|
}); |
|
44
|
12 |
|
$this->app->bindIf(Api::class, function (Application $app) { |
|
|
|
|
|
|
45
|
1 |
|
return new Api( |
|
46
|
1 |
|
config('gocardless-payment.access_token'), |
|
47
|
1 |
|
config('gocardless-payment.environment'), |
|
48
|
1 |
|
); |
|
49
|
12 |
|
}); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
12 |
|
protected function registerMigrations(): void |
|
53
|
|
|
{ |
|
54
|
12 |
|
if (GoCardlessPayment::$runsMigrations) { |
|
55
|
12 |
|
$this->loadMigrationsFrom(__DIR__.'/../database/migrations'); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
12 |
|
protected function registerRoutes(): void |
|
60
|
|
|
{ |
|
61
|
12 |
|
if (! GoCardlessPayment::$useRoutes) { |
|
62
|
|
|
return; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
12 |
|
\Illuminate\Support\Facades\Route::group([ |
|
66
|
12 |
|
'prefix' => config('gocardless-payment.web.path_prefix'), |
|
67
|
12 |
|
'as' => 'gocardless-payment.', |
|
68
|
12 |
|
], function () { |
|
69
|
12 |
|
$this->loadRoutesFrom(__DIR__.'/../routes/web.php'); |
|
70
|
12 |
|
}); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.