1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Orkhanahmadov\LaravelGoldenpay; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\Route; |
6
|
|
|
use Illuminate\Support\ServiceProvider; |
7
|
|
|
use Orkhanahmadov\Goldenpay\PaymentInterface; |
8
|
|
|
use Orkhanahmadov\Goldenpay\Goldenpay as Library; |
9
|
|
|
use Orkhanahmadov\LaravelGoldenpay\Commands\ResultCommand; |
10
|
|
|
use Orkhanahmadov\LaravelGoldenpay\Tests\FakeResultController; |
11
|
|
|
|
12
|
|
|
class LaravelGoldenpayServiceProvider extends ServiceProvider |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* Bootstrap the application services. |
16
|
|
|
*/ |
17
|
|
|
public function boot() |
18
|
|
|
{ |
19
|
|
|
$this->app->bind(PaymentInterface::class, Library::class); |
20
|
|
|
|
21
|
|
|
if ($this->app->runningInConsole()) { |
22
|
|
|
$this->publishes([ |
23
|
|
|
__DIR__.'/../config/config.php' => config_path('goldenpay.php'), |
24
|
|
|
], 'config'); |
25
|
|
|
|
26
|
|
|
if (! class_exists('CreateGoldenpayPaymentsTable')) { |
27
|
|
|
$this->publishes([ |
28
|
|
|
__DIR__.'/../database/migrations/goldenpay_payments_table.php.stub' => |
29
|
|
|
database_path('migrations/'.date('Y_m_d_His').'_create_goldenpay_payments_table.php'), |
30
|
|
|
], 'migrations'); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
$this->commands([ |
34
|
|
|
ResultCommand::class, |
35
|
|
|
]); |
36
|
|
|
|
37
|
|
|
$this->registerRoutes(); |
38
|
|
|
} |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Register the application services. |
43
|
|
|
*/ |
44
|
|
|
public function register() |
45
|
|
|
{ |
46
|
|
|
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'goldenpay'); |
47
|
|
|
|
48
|
|
|
$this->app->singleton('goldenpay', function () { |
49
|
|
|
return $this->app->make(Goldenpay::class); |
50
|
|
|
}); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Registers package routes. |
55
|
|
|
*/ |
56
|
|
|
private function registerRoutes(): void |
57
|
|
|
{ |
58
|
|
|
if ($this->app->environment('testing')) { |
59
|
|
|
Route::get('__goldenpay-fake-test-route__', [FakeResultController::class, 'index']); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|