|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Neo\EarlyAccess; |
|
4
|
|
|
|
|
5
|
|
|
use Neo\EarlyAccess\Console\Commands; |
|
6
|
|
|
use Illuminate\Support\ServiceProvider; |
|
7
|
|
|
use Neo\EarlyAccess\Events\UserSubscribed; |
|
8
|
|
|
use Neo\EarlyAccess\Events\UserUnsubscribed; |
|
9
|
|
|
use Neo\EarlyAccess\SubscriptionServices\DatabaseService; |
|
10
|
|
|
use Neo\EarlyAccess\Listeners\SendUnsubscribeNotification; |
|
11
|
|
|
use Neo\EarlyAccess\Listeners\SendSubscriptionNotification; |
|
12
|
|
|
use Neo\EarlyAccess\Contracts\Subscription\SubscriptionProvider; |
|
13
|
|
|
use Neo\EarlyAccess\SubscriptionServices\Repositories\Database\EloquentRepository; |
|
14
|
|
|
|
|
15
|
|
|
class EarlyAccessServiceProvider extends ServiceProvider |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* Perform post-registration booting of services. |
|
19
|
|
|
* |
|
20
|
|
|
* @return void |
|
21
|
|
|
*/ |
|
22
|
|
|
public function boot() |
|
23
|
|
|
{ |
|
24
|
|
|
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); |
|
25
|
|
|
|
|
26
|
|
|
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'early-access'); |
|
27
|
|
|
|
|
28
|
|
|
$this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'early-access'); |
|
29
|
|
|
|
|
30
|
|
|
$this->app['router']->namespace('Neo\\EarlyAccess\\Http\\Controllers') |
|
31
|
|
|
->middleware(['web']) |
|
32
|
|
|
->group(function () { |
|
33
|
|
|
$this->loadRoutesFrom(__DIR__ . '/../routes/web.php'); |
|
34
|
|
|
}); |
|
35
|
|
|
|
|
36
|
|
|
$this->registerEventListeners(); |
|
37
|
|
|
|
|
38
|
|
|
if ($this->app->runningInConsole()) { |
|
39
|
|
|
$this->bootForConsole(); |
|
40
|
|
|
} |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Register any package services. |
|
45
|
|
|
* |
|
46
|
|
|
* @return void |
|
47
|
|
|
*/ |
|
48
|
|
|
public function register() |
|
49
|
|
|
{ |
|
50
|
|
|
$this->mergeConfigFrom(__DIR__ . '/../config/early-access.php', 'early-access'); |
|
51
|
|
|
|
|
52
|
|
|
$this->app->singleton('early-access', function ($app) { |
|
53
|
|
|
return new EarlyAccess($app['filesystem.disk'], $app['auth.driver']); |
|
54
|
|
|
}); |
|
55
|
|
|
|
|
56
|
|
|
$this->app->bind('early-access.database', function () { |
|
57
|
|
|
return new DatabaseService(new EloquentRepository); |
|
58
|
|
|
}); |
|
59
|
|
|
|
|
60
|
|
|
$this->app->bind(SubscriptionProvider::class, function () { |
|
61
|
|
|
return app('early-access.' . config('early-access.service')); |
|
62
|
|
|
}); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Get the services provided by the provider. |
|
67
|
|
|
* |
|
68
|
|
|
* @return array |
|
69
|
|
|
*/ |
|
70
|
|
|
public function provides() |
|
71
|
|
|
{ |
|
72
|
|
|
return ['early-access']; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Console-specific booting. |
|
77
|
|
|
* |
|
78
|
|
|
* @return void |
|
79
|
|
|
*/ |
|
80
|
|
|
protected function bootForConsole() |
|
81
|
|
|
{ |
|
82
|
|
|
$this->publishes([ |
|
83
|
|
|
__DIR__ . '/../config/early-access.php' => config_path('early-access.php'), |
|
84
|
|
|
], 'config'); |
|
85
|
|
|
|
|
86
|
|
|
$this->publishes([ |
|
87
|
|
|
__DIR__ . '/../resources/views' => base_path('resources/views/vendor/early-access'), |
|
88
|
|
|
], 'views'); |
|
89
|
|
|
|
|
90
|
|
|
$this->publishes([ |
|
91
|
|
|
__DIR__ . '/../public' => public_path('vendor/early-access'), |
|
92
|
|
|
], 'assets'); |
|
93
|
|
|
|
|
94
|
|
|
$this->publishes([ |
|
95
|
|
|
__DIR__ . '/../database/migrations/' => database_path('migrations'), |
|
96
|
|
|
], 'migrations'); |
|
97
|
|
|
|
|
98
|
|
|
$this->publishes([ |
|
99
|
|
|
__DIR__ . '/../resources/lang' => resource_path('lang/vendor/early-access'), |
|
100
|
|
|
], 'translations'); |
|
101
|
|
|
|
|
102
|
|
|
$this->commands([ |
|
103
|
|
|
Commands\EarlyAccess::class, |
|
104
|
|
|
]); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* Register the packages event listeners. |
|
109
|
|
|
*/ |
|
110
|
|
|
protected function registerEventListeners() |
|
111
|
|
|
{ |
|
112
|
|
|
$this->app['events']->listen(UserSubscribed::class, SendSubscriptionNotification::class); |
|
113
|
|
|
|
|
114
|
|
|
$this->app['events']->listen(UserUnsubscribed::class, SendUnsubscribeNotification::class); |
|
115
|
|
|
} |
|
116
|
|
|
} |
|
117
|
|
|
|