1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 17:54:03 +00:00
tenancy/src/Database/Concerns/MaintenanceMode.php
2022-10-17 11:24:22 -04:00

36 lines
983 B
PHP

<?php
declare(strict_types=1);
namespace Stancl\Tenancy\Database\Concerns;
use Stancl\Tenancy\Events\TenantMaintenanceModeDisabled;
use Stancl\Tenancy\Events\TenantMaintenanceModeEnabled;
/**
* @mixin \Illuminate\Database\Eloquent\Model
*/
trait MaintenanceMode
{
public function putDownForMaintenance($data = []): void
{
$this->update([
'maintenance_mode' => [
'except' => $data['except'] ?? null,
'redirect' => $data['redirect'] ?? null,
'retry' => $data['retry'] ?? null,
'refresh' => $data['refresh'] ?? null,
'secret' => $data['secret'] ?? null,
'status' => $data['status'] ?? 503,
],
]);
event(new TenantMaintenanceModeEnabled($this));
}
public function bringUpFromMaintenance(): void
{
$this->update(['maintenance_mode' => null]);
event(new TenantMaintenanceModeDisabled($this));
}
}