diff --git a/readme.md b/readme.md index 544a886..e665194 100644 --- a/readme.md +++ b/readme.md @@ -16,7 +16,7 @@ You can install the package with composer composer require justijndepover/laravel-inbox ``` -After the installation, you should publish the assets +After the installation, you have to publish the assets ``` php artisan inbox:install ``` diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php new file mode 100644 index 0000000..dfd622f --- /dev/null +++ b/src/Console/InstallCommand.php @@ -0,0 +1,26 @@ +comment('Publishing assets...'); + + $this->callSilent('vendor:publish', ['--tag' => 'laravel-inbox-assets']); + + if ($this->option('config')) { + $this->comment('Publishing configuration...'); + $this->callSilent('vendor:publish', ['--tag' => 'laravel-inbox-config']); + } + + $this->info('Laravel Inbox installed successfully.'); + } +} \ No newline at end of file diff --git a/src/InboxServiceProvider.php b/src/InboxServiceProvider.php index de95e68..da8d4e3 100644 --- a/src/InboxServiceProvider.php +++ b/src/InboxServiceProvider.php @@ -6,6 +6,7 @@ use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Gate; use Illuminate\Support\ServiceProvider; +use Justijndepover\Inbox\Console\InstallCommand; use Justijndepover\Inbox\Listeners\EmailLogger; class InboxServiceProvider extends ServiceProvider @@ -13,6 +14,8 @@ class InboxServiceProvider extends ServiceProvider public function register() { $this->mergeConfigFrom(__DIR__ . '/../config/inbox.php', 'inbox'); + + $this->commands(InstallCommand::class); } public function boot() @@ -20,7 +23,7 @@ public function boot() if ($this->app->runningInConsole()) { $this->publishes([ __DIR__ . '/../config/inbox.php' => config_path('inbox.php'), - ]); + ], 'laravel-inbox-config'); $this->loadMigrationsFrom(__DIR__ . '/../database/migrations');