mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-13 09:44:03 +00:00
[4.x] Add command to bring the tenants up and down from maintenance and remove deprecated exception (#761)
* Add bring up from maintenance function * Add up and down tenant maintenance commands * Rename commands signatures * Update TenancyServiceProvider.php * Complying to Laravel maintenance code and parameters * Update MaintenanceModeTest.php * Add maintenance mode via commands test * Update CheckTenantForMaintenanceMode.php * Update MaintenanceModeTest.php * Cookie bypass only for > Laravel 8 * minor formatting change, trigger CI * clean * Update MaintenanceModeTest.php * Add comments for using the 'tenants' option in runForMultiple * improve code * php-cs-fixer * fix php cs fixer config * improve test logic * remove version check since v4 will be L9+ Co-authored-by: Samuel Štancl <samuel@archte.ch> Co-authored-by: lukinovec <lukinovec@gmail.com> Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
This commit is contained in:
parent
e009f6700c
commit
121370ea01
9 changed files with 161 additions and 25 deletions
|
|
@ -4,17 +4,27 @@ declare(strict_types=1);
|
|||
|
||||
namespace Stancl\Tenancy\Database\Concerns;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* @mixin \Illuminate\Database\Eloquent\Model
|
||||
*/
|
||||
trait MaintenanceMode
|
||||
{
|
||||
public function putDownForMaintenance($data = [])
|
||||
public function putDownForMaintenance($data = []): void
|
||||
{
|
||||
$this->update(['maintenance_mode' => [
|
||||
'time' => $data['time'] ?? Carbon::now()->getTimestamp(),
|
||||
'message' => $data['message'] ?? null,
|
||||
'retry' => $data['retry'] ?? null,
|
||||
'allowed' => $data['allowed'] ?? [],
|
||||
]]);
|
||||
$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,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function bringUpFromMaintenance(): void
|
||||
{
|
||||
$this->update(['maintenance_mode' => null]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue