mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-04 20:34:03 +00:00
wip
This commit is contained in:
parent
aca5567c10
commit
e71e4e8d28
3 changed files with 77 additions and 10 deletions
76
src/Commands/Install.php
Normal file
76
src/Commands/Install.php
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Stancl\Tenancy\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class Install extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'tenancy:install';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Install stancl/tenancy.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$this->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'),
|
||||||
|
"<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Web Routes
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here is where you can register tenat routes for your application. These
|
||||||
|
| routes are loaded by the TenantRouteServiceProvider within a group
|
||||||
|
| which contains the \"InitializeTenancy\" middleware. Good luck!
|
||||||
|
|
|
||||||
|
|
||||||
|
Route::get('/your/application/homepage', function () {
|
||||||
|
return 'This is your multi-tenant application. The uuid of the current tenant is ' . tenant('uuid');
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
");
|
||||||
|
$this->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 ✨.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -20,16 +20,6 @@ class TenantList extends Command
|
||||||
*/
|
*/
|
||||||
protected $description = 'List tenants.';
|
protected $description = 'List tenants.';
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new command instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ class TenancyServiceProvider extends ServiceProvider
|
||||||
$this->commands([
|
$this->commands([
|
||||||
Run::class,
|
Run::class,
|
||||||
Seed::class,
|
Seed::class,
|
||||||
|
Install::class,
|
||||||
Migrate::class,
|
Migrate::class,
|
||||||
Rollback::class,
|
Rollback::class,
|
||||||
TenantList::class,
|
TenantList::class,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue