mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 19:14:03 +00:00
Add up and down tenant maintenance commands
This commit is contained in:
parent
ec979655d2
commit
db9113007a
2 changed files with 95 additions and 0 deletions
52
src/Commands/Down.php
Normal file
52
src/Commands/Down.php
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Stancl\Tenancy\Concerns\HasATenantsOption;
|
||||
|
||||
class Down extends Command
|
||||
{
|
||||
use HasATenantsOption;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
||||
protected $signature = 'tenants:down
|
||||
{--time= : The time when the app has been set to maintenance mode}
|
||||
{--message= : Message to display}
|
||||
{--retry= : The number of seconds after which the request may be retried}
|
||||
{--allowed=* : List of IPs allowed}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Put tenants into maintenance';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
tenancy()->runForMultiple($this->option('tenants'), function ($tenant) {
|
||||
$this->line("Tenant: {$tenant['id']}");
|
||||
$tenant->putDownForMaintenance([
|
||||
'time' => $this->option('time'),
|
||||
'message' => $this->option('message'),
|
||||
'retry' => $this->option('retry'),
|
||||
'allowed' => $this->option('allowed'),
|
||||
]);
|
||||
});
|
||||
|
||||
$this->comment('Tenants are now in maintenance mode.');
|
||||
}
|
||||
}
|
||||
43
src/Commands/Up.php
Normal file
43
src/Commands/Up.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy\Commands;;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Stancl\Tenancy\Concerns\HasATenantsOption;
|
||||
|
||||
class Up extends Command
|
||||
{
|
||||
use HasATenantsOption;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
||||
protected $signature = 'tenants:up';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Put tenants out of maintenance';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
tenancy()->runForMultiple($this->option('tenants'), function ($tenant) {
|
||||
$this->line("Tenant: {$tenant['id']}");
|
||||
$tenant->bringUpFromMaintenance();
|
||||
});
|
||||
|
||||
$this->comment('Tenants are now out of maintenance mode.');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue