mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-06 03:14:04 +00:00
Using laravel components
This commit is contained in:
parent
6ee93d0441
commit
2f15dd5473
10 changed files with 142 additions and 59 deletions
|
|
@ -14,40 +14,93 @@ class Install extends Command
|
|||
|
||||
public function handle(): void
|
||||
{
|
||||
$this->comment('Installing stancl/tenancy...');
|
||||
$this->callSilent('vendor:publish', [
|
||||
'--provider' => 'Stancl\Tenancy\TenancyServiceProvider',
|
||||
'--tag' => 'config',
|
||||
]);
|
||||
$this->info('✔️ Created config/tenancy.php');
|
||||
$this->newLine();
|
||||
|
||||
if (! file_exists(base_path('routes/tenant.php'))) {
|
||||
$this->components->task('Publishing config file', function () {
|
||||
$this->callSilent('vendor:publish', [
|
||||
'--provider' => 'Stancl\Tenancy\TenancyServiceProvider',
|
||||
'--tag' => 'routes',
|
||||
'--tag' => 'config',
|
||||
]);
|
||||
$this->info('✔️ Created routes/tenant.php');
|
||||
});
|
||||
|
||||
$this->patienceIsKeyToLife();
|
||||
$this->newLine();
|
||||
|
||||
if (!file_exists(base_path('routes/tenant.php'))) {
|
||||
$this->components->task('Publishing routes', function () {
|
||||
$this->callSilent('vendor:publish', [
|
||||
'--provider' => 'Stancl\Tenancy\TenancyServiceProvider',
|
||||
'--tag' => 'routes',
|
||||
]);
|
||||
});
|
||||
$this->newLine();
|
||||
} else {
|
||||
$this->info('Found routes/tenant.php.');
|
||||
$this->components->warn('File [routes/tenant.php] already existe.');
|
||||
}
|
||||
|
||||
$this->callSilent('vendor:publish', [
|
||||
'--provider' => 'Stancl\Tenancy\TenancyServiceProvider',
|
||||
'--tag' => 'providers',
|
||||
]);
|
||||
$this->info('✔️ Created TenancyServiceProvider.php');
|
||||
$this->patienceIsKeyToLife();
|
||||
|
||||
$this->callSilent('vendor:publish', [
|
||||
'--provider' => 'Stancl\Tenancy\TenancyServiceProvider',
|
||||
'--tag' => 'migrations',
|
||||
]);
|
||||
$this->info('✔️ Created migrations. Remember to run [php artisan migrate]!');
|
||||
$this->components->task('Publishing providers', function () {
|
||||
$this->callSilent('vendor:publish', [
|
||||
'--provider' => 'Stancl\Tenancy\TenancyServiceProvider',
|
||||
'--tag' => 'providers',
|
||||
]);
|
||||
});
|
||||
|
||||
if (! is_dir(database_path('migrations/tenant'))) {
|
||||
mkdir(database_path('migrations/tenant'));
|
||||
$this->info('✔️ Created database/migrations/tenant folder.');
|
||||
$this->patienceIsKeyToLife();
|
||||
$this->newLine();
|
||||
|
||||
$this->components->task('Publishing migrations', function () {
|
||||
$this->callSilent('vendor:publish', [
|
||||
'--provider' => 'Stancl\Tenancy\TenancyServiceProvider',
|
||||
'--tag' => 'migrations',
|
||||
]);
|
||||
});
|
||||
|
||||
$this->patienceIsKeyToLife();
|
||||
$this->newLine();
|
||||
|
||||
if (!is_dir(database_path('migrations/tenant'))) {
|
||||
$this->components->task('Creating database/migrations/tenant folder', function () {
|
||||
mkdir(database_path('migrations/tenant'));
|
||||
});
|
||||
} else {
|
||||
$this->components->warn('Folder [database/migrations/tenant] already existe.');
|
||||
}
|
||||
|
||||
$this->comment('✨️ stancl/tenancy installed successfully.');
|
||||
$this->components->info('✨️ stancl/tenancy installed successfully.');
|
||||
|
||||
$this->patienceIsKeyToLife();
|
||||
$this->askForSupport();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause the console execution for 1 second, help the user to have time and read the output
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function patienceIsKeyToLife(): void
|
||||
{
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the user accepts, opens the GitHub project in the browser
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function askForSupport(): void
|
||||
{
|
||||
if ($this->components->confirm("Would you like to show your support by starring the project on github ?", true)) {
|
||||
if (PHP_OS_FAMILY === 'Darwin') {
|
||||
exec('open https://github.com/archtechx/tenancy');
|
||||
}
|
||||
if (PHP_OS_FAMILY === 'Windows') {
|
||||
exec('start https://github.com/archtechx/tenancy');
|
||||
}
|
||||
if (PHP_OS_FAMILY === 'Linux') {
|
||||
exec('xdg-open https://github.com/archtechx/tenancy');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue