mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 15:34:04 +00:00
first implementation
This commit is contained in:
parent
67172a1176
commit
cfaa6463ee
6 changed files with 99 additions and 23 deletions
|
|
@ -3,12 +3,10 @@
|
|||
namespace Stancl\Tenancy\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Stancl\Tenancy\DatabaseManager;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class Run extends Command
|
||||
{
|
||||
protected $database;
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
|
|
@ -21,18 +19,7 @@ class Run extends Command
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'tenants:run {command} {--tenants} {args*}';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(DatabaseManager $database)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->database = $database;
|
||||
}
|
||||
protected $signature = 'tenants:run {commandname} {--tenants=} {args*}';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
|
|
@ -41,8 +28,8 @@ class Run extends Command
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
if (! $this->confirmToProceed()) {
|
||||
return;
|
||||
if ($tenancy_was_initialized = tenancy()->initialized) {
|
||||
$previous_tenants_domain = tenant('domain');
|
||||
}
|
||||
|
||||
tenant()->all($this->option('tenants'))->each(function ($tenant) {
|
||||
|
|
@ -50,9 +37,14 @@ class Run extends Command
|
|||
tenancy()->init($tenant['domain']);
|
||||
|
||||
// Run command
|
||||
// todo
|
||||
Artisan::call($this->argument('commandname'), [
|
||||
'args' => $this->argument('args') // todo find a better way to pass args
|
||||
]);
|
||||
tenancy()->end();
|
||||
});
|
||||
|
||||
// todo reconnect to previous tenant or end tenancy if it hadn't been started
|
||||
if ($tenancy_was_initialized) {
|
||||
tenancy()->init($previous_tenants_domain);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Stancl\Tenancy;
|
||||
|
||||
use Stancl\Tenancy\Commands\Run;
|
||||
use Stancl\Tenancy\Commands\Seed;
|
||||
use Illuminate\Cache\CacheManager;
|
||||
use Stancl\Tenancy\Commands\Migrate;
|
||||
|
|
@ -23,9 +24,10 @@ class TenancyServiceProvider extends ServiceProvider
|
|||
{
|
||||
if ($this->app->runningInConsole()) {
|
||||
$this->commands([
|
||||
Run::class,
|
||||
Seed::class,
|
||||
Migrate::class,
|
||||
Rollback::class,
|
||||
Seed::class,
|
||||
TenantList::class,
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue