From d6559d64306030268937dcba2d74ad1527123cb3 Mon Sep 17 00:00:00 2001 From: Arthur Monney Date: Tue, 3 Oct 2023 08:15:45 +0200 Subject: [PATCH 1/2] Add install command --- src/SubscriptionServiceProvider.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/SubscriptionServiceProvider.php b/src/SubscriptionServiceProvider.php index f24d720..06b4856 100755 --- a/src/SubscriptionServiceProvider.php +++ b/src/SubscriptionServiceProvider.php @@ -4,6 +4,7 @@ namespace Laravelcm\Subscriptions; +use Spatie\LaravelPackageTools\Commands\InstallCommand; use Spatie\LaravelPackageTools\Package; use Spatie\LaravelPackageTools\PackageServiceProvider; @@ -12,11 +13,12 @@ final class SubscriptionServiceProvider extends PackageServiceProvider public function configurePackage(Package $package): void { $package->name('laravel-subscriptions') - ->hasConfigFile('laravel-subscriptions'); - } - - public function bootingPackage(): void - { - $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); + ->hasConfigFile('laravel-subscriptions') + ->hasInstallCommand(function (InstallCommand $command): void { + $command + ->publishConfigFile() + ->publishMigrations() + ->askToStarRepoOnGitHub('laravelcm/laravel-subscriptions'); + }); } } From 92e14f248d01673938f873afe5b715509eb51cba Mon Sep 17 00:00:00 2001 From: Arthur Monney Date: Tue, 3 Oct 2023 08:20:21 +0200 Subject: [PATCH 2/2] Add load migrations for app run in console --- src/SubscriptionServiceProvider.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/SubscriptionServiceProvider.php b/src/SubscriptionServiceProvider.php index 06b4856..fb06f9c 100755 --- a/src/SubscriptionServiceProvider.php +++ b/src/SubscriptionServiceProvider.php @@ -21,4 +21,11 @@ public function configurePackage(Package $package): void ->askToStarRepoOnGitHub('laravelcm/laravel-subscriptions'); }); } + + public function bootingPackage(): void + { + if ($this->app->runningInConsole()) { + $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); + } + } }