diff --git a/src/Commands/Install.php b/src/Commands/Install.php new file mode 100644 index 00000000..a57406fe --- /dev/null +++ b/src/Commands/Install.php @@ -0,0 +1,76 @@ +line('Installing stancl/tenancy... ⌛'); + $this->call('vendor:publish', [ + '--provider' => 'Stancl\Tenancy\TenancyServiceProvider', + '--tag' => 'config', + ]); + $this->info('✔️ Created config/tenancy.php'); + + file_put_contents(app_path('Http/Kernel.php'), str_replace( + 'protected $middlewarePriority = [', + 'protected $middlewarePriority = [\n \Stancl\Tenancy\Middleware\InitializeTenancy::class', + file_get_contents(app_path('Http/Kernel.php')) + )); + $this->info('✔️ Set middleware priority'); + + file_put_contents(base_path('routes/tenant.php'), +"info('✔️ Created routes/tenant.php'); + + $this->line("The package lets you store data about tenants either in Redis or in a relational database like MySQL. If you're going to use the database storage, you need to create a tenants table."); + $migration = $this->ask('Do you want to publish the default database migration? [yes/no]', 'yes'); + if (\strtolower($migration) === 'yes') { + $this->call('vendor:publish', [ + '--provider' => 'Stancl\Tenancy\TenancyServiceProvider', + '--tag' => 'migrations', + ]); + $this->info('✔️ Created migration.'); + } + + $this->info('\n✔️stancl/tenancy installed successfully ✨.'); + } +} diff --git a/src/Commands/TenantList.php b/src/Commands/TenantList.php index 6a8fc400..a1d2b049 100644 --- a/src/Commands/TenantList.php +++ b/src/Commands/TenantList.php @@ -20,16 +20,6 @@ class TenantList extends Command */ protected $description = 'List tenants.'; - /** - * Create a new command instance. - * - * @return void - */ - public function __construct() - { - parent::__construct(); - } - /** * Execute the console command. * diff --git a/src/TenancyServiceProvider.php b/src/TenancyServiceProvider.php index 4ac33bd5..7e70f5d8 100644 --- a/src/TenancyServiceProvider.php +++ b/src/TenancyServiceProvider.php @@ -25,6 +25,7 @@ class TenancyServiceProvider extends ServiceProvider $this->commands([ Run::class, Seed::class, + Install::class, Migrate::class, Rollback::class, TenantList::class,