1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Rinvex\Subscriptions\Providers; |
6
|
|
|
|
7
|
|
|
use Rinvex\Subscriptions\Models\Plan; |
8
|
|
|
use Illuminate\Support\ServiceProvider; |
9
|
|
|
use Rinvex\Support\Traits\ConsoleTools; |
10
|
|
|
use Rinvex\Subscriptions\Models\PlanFeature; |
11
|
|
|
use Rinvex\Subscriptions\Models\PlanSubscription; |
12
|
|
|
use Rinvex\Subscriptions\Models\PlanSubscriptionUsage; |
13
|
|
|
use Rinvex\Subscriptions\Console\Commands\MigrateCommand; |
14
|
|
|
use Rinvex\Subscriptions\Console\Commands\PublishCommand; |
15
|
|
|
use Rinvex\Subscriptions\Console\Commands\RollbackCommand; |
16
|
|
|
|
17
|
|
|
class SubscriptionsServiceProvider extends ServiceProvider |
18
|
|
|
{ |
19
|
|
|
use ConsoleTools; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* The commands to be registered. |
23
|
|
|
* |
24
|
|
|
* @var array |
25
|
|
|
*/ |
26
|
|
|
protected $commands = [ |
27
|
|
|
MigrateCommand::class => 'command.rinvex.subscriptions.migrate', |
28
|
|
|
PublishCommand::class => 'command.rinvex.subscriptions.publish', |
29
|
|
|
RollbackCommand::class => 'command.rinvex.subscriptions.rollback', |
30
|
|
|
]; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Register the application services. |
34
|
|
|
* |
35
|
|
|
* @return void |
36
|
|
|
*/ |
37
|
|
|
public function register(): void |
38
|
|
|
{ |
39
|
|
|
$this->mergeConfigFrom(realpath(__DIR__.'/../../config/config.php'), 'rinvex.subscriptions'); |
40
|
|
|
|
41
|
|
|
// Bind eloquent models to IoC container |
42
|
|
|
$this->app->singleton('rinvex.subscriptions.plan', $planModel = $this->app['config']['rinvex.subscriptions.models.plan']); |
|
|
|
|
43
|
|
|
$planModel === Plan::class || $this->app->alias('rinvex.subscriptions.plan', Plan::class); |
44
|
|
|
|
45
|
|
|
$this->app->singleton('rinvex.subscriptions.plan_feature', $planFeatureModel = $this->app['config']['rinvex.subscriptions.models.plan_feature']); |
|
|
|
|
46
|
|
|
$planFeatureModel === PlanFeature::class || $this->app->alias('rinvex.subscriptions.plan_feature', PlanFeature::class); |
|
|
|
|
47
|
|
|
|
48
|
|
|
$this->app->singleton('rinvex.subscriptions.plan_subscription', $planSubscriptionModel = $this->app['config']['rinvex.subscriptions.models.plan_subscription']); |
|
|
|
|
49
|
|
|
$planSubscriptionModel === PlanSubscription::class || $this->app->alias('rinvex.subscriptions.plan_subscription', PlanSubscription::class); |
|
|
|
|
50
|
|
|
|
51
|
|
|
$this->app->singleton('rinvex.subscriptions.plan_subscription_usage', $planSubscriptionUsageModel = $this->app['config']['rinvex.subscriptions.models.plan_subscription_usage']); |
|
|
|
|
52
|
|
|
$planSubscriptionUsageModel === PlanSubscriptionUsage::class || $this->app->alias('rinvex.subscriptions.plan_subscription_usage', PlanSubscriptionUsage::class); |
|
|
|
|
53
|
|
|
|
54
|
|
|
// Register console commands |
55
|
|
|
! $this->app->runningInConsole() || $this->registersCommands(); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Bootstrap the application services. |
60
|
|
|
* |
61
|
|
|
* @return void |
62
|
|
|
*/ |
63
|
|
|
public function boot(): void |
64
|
|
|
{ |
65
|
|
|
// Publish Resources |
66
|
|
|
! $this->app->runningInConsole() || $this->publishesConfig('rinvex/laravel-subscriptions'); |
67
|
|
|
! $this->app->runningInConsole() || $this->publishesMigrations('rinvex/laravel-subscriptions'); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.