Add maintenance pages
This commit is contained in:
22
app/Console/Commands/SubmissionsDown.php
Normal file
22
app/Console/Commands/SubmissionsDown.php
Normal 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.");
|
||||
}
|
||||
}
|
||||
22
app/Console/Commands/SubmissionsUp.php
Normal file
22
app/Console/Commands/SubmissionsUp.php
Normal 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.');
|
||||
}
|
||||
}
|
||||
33
app/Http/Middleware/SubmissionsEnabled.php
Normal file
33
app/Http/Middleware/SubmissionsEnabled.php
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -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."
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user