Skip to content

Instantly share code, notes, and snippets.

@Muetze42
Created December 31, 2021 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Muetze42/ce4ae7d53735d9a28a67b104f76ddd2f to your computer and use it in GitHub Desktop.
Save Muetze42/ce4ae7d53735d9a28a67b104f76ddd2f to your computer and use it in GitHub Desktop.
Laravel: Default View For Maintenance Mode
<?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