1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 15:14:04 +00:00

Add maintenance events

This commit is contained in:
j.stein 2022-10-08 18:17:30 -04:00
parent df70463331
commit d52254eb94
4 changed files with 26 additions and 0 deletions

View file

@ -58,6 +58,8 @@ class TenancyServiceProvider extends ServiceProvider
return $event->tenant;
})->shouldBeQueued(false), // `false` by default, but you probably want to make this `true` for production.
],
Events\TenantMaintenanceModeEnabled::class => [],
Events\TenantMaintenanceModeDisabled::class => [],
// Domain events
Events\CreatingDomain::class => [],

View file

@ -5,6 +5,8 @@ declare(strict_types=1);
namespace Stancl\Tenancy\Database\Concerns;
use Illuminate\Contracts\Container\BindingResolutionException;
use Stancl\Tenancy\Events\TenantMaintenanceModeDisabled;
use Stancl\Tenancy\Events\TenantMaintenanceModeEnabled;
use Stancl\Tenancy\Maintenance\TenantMaintenanceModeContract;
/**
@ -33,6 +35,8 @@ trait MaintenanceMode
public function putDownForMaintenance(array $payload = []): void
{
$this->maintenanceMode()->activate($payload);
event(new TenantMaintenanceModeEnabled($this));
}
/**
@ -44,6 +48,8 @@ trait MaintenanceMode
public function bringUpFromMaintenance(): void
{
$this->maintenanceMode()->deactivate();
event(new TenantMaintenanceModeDisabled($this));
}
/**

View file

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Stancl\Tenancy\Events;
class TenantMaintenanceModeDisabled extends Contracts\TenantEvent
{
}

View file

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Stancl\Tenancy\Events;
class TenantMaintenanceModeEnabled extends Contracts\TenantEvent
{
}