Created
December 31, 2021 20:25
-
-
Save Muetze42/ce4ae7d53735d9a28a67b104f76ddd2f to your computer and use it in GitHub Desktop.
Laravel: Default View For Maintenance Mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Console\Commands; | |
use Illuminate\Foundation\Console\DownCommand as Command; | |
use Illuminate\Foundation\Exceptions\RegisterErrorViewPaths; | |
class DownCommand extends Command | |
{ | |
/** | |
* The default view for the maintenance mode | |
* | |
* @var string | |
*/ | |
protected string $defaultMaintenanceView = 'errors::503'; | |
/** | |
* Get the payload to be placed in the "down" file. | |
* | |
* @return array | |
*/ | |
protected function getDownFilePayload(): array | |
{ | |
return [ | |
'except' => $this->excludedPaths(), | |
'redirect' => $this->redirectPath(), | |
'retry' => $this->getRetryTime(), | |
'refresh' => $this->option('refresh'), | |
'secret' => $this->option('secret'), | |
'status' => (int) $this->option('status', 503), | |
'template' => $this->prerenderView(), | |
]; | |
} | |
/** | |
* Prerender the specified view so that it can be rendered even before loading Composer. | |
* | |
* @return string | |
*/ | |
protected function prerenderView(): string | |
{ | |
(new RegisterErrorViewPaths)(); | |
return view(($this->option('render') ? $this->option('render') : $this->defaultMaintenanceView), [ | |
'retryAfter' => $this->option('retry'), | |
])->render(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment