Add maintenance pages

This commit is contained in:
2026-06-29 11:47:19 +02:00
parent bb8fdac460
commit 1abfa96c2c
12 changed files with 740 additions and 14 deletions

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
#[Signature('submissions:down')]
#[Description('Disable submissions')]
class SubmissionsDown extends Command
{
/**
* Execute the console command.
*/
public function handle()
{
Cache::put('submissions_maintenance', true );
$this->info("Submissions disabled.");
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
#[Signature('submissions:up')]
#[Description('Enable submissions')]
class SubmissionsUp extends Command
{
/**
* Execute the console command.
*/
public function handle()
{
Cache::forget('submissions_maintenance');
$this->info('Submissions enabled.');
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Symfony\Component\HttpFoundation\Response;
class SubmissionsEnabled
{
/**
* Handle an incoming request.
*
* @param Closure(Request): (Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
if( Cache::get('submissions_maintenance', false ) ){
if( $request->expectsJson() ){
return response()->json([
'message' => 'The submissions are currently in maintenance mode.',
], 503 );
}
return back()->withErrors([
'maintenance' => "The submissions are currently in maintenance mode.",
])->withInput();
}
return $next($request);
}
}

View File

@@ -14,6 +14,10 @@ class ErrorBlock extends Component
'icon' => 'ban',
'message' => '%s'
],
'not-found' => [
'icon' => 'sticky-note-off',
'message' => "404: This page does not exist."
],
'page-not-allowed' => [
'icon' => 'shield-ban',
'message' => "You do not have permission to access this page.\nRequired permission: %s"
@@ -21,6 +25,10 @@ class ErrorBlock extends Component
'user-state-not-valid' => [
'icon' => 'shield-ban',
'message' => "You do not have permission to access this page.\nYour user profile is incomplete: %s\nGo back to the forum for more details."
],
'server-error' => [
'icon' => 'bomb',
'message' => "500: Internal Server Error."
]
];