feat: Phase 2 - page CRUD, subscriber management, user management
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Middleware\CheckRole;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Foundation\Configuration\Exceptions;
|
||||
use Illuminate\Foundation\Configuration\Middleware;
|
||||
use Illuminate\Http\Exceptions\PostTooLargeException;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
return Application::configure(basePath: dirname(__DIR__))
|
||||
->withRouting(
|
||||
@@ -12,9 +15,33 @@ return Application::configure(basePath: dirname(__DIR__))
|
||||
)
|
||||
->withMiddleware(function (Middleware $middleware): void {
|
||||
$middleware->alias([
|
||||
'role' => \App\Http\Middleware\CheckRole::class,
|
||||
'role' => CheckRole::class,
|
||||
]);
|
||||
})
|
||||
->withExceptions(function (Exceptions $exceptions): void {
|
||||
//
|
||||
$exceptions->renderable(function (PostTooLargeException $e, Request $request) {
|
||||
$contentLength = (int) $request->server('CONTENT_LENGTH', 0);
|
||||
$contentLengthMb = $contentLength > 0 ? $contentLength / 1048576 : 0;
|
||||
$postMaxSize = ini_get('post_max_size') ?: 'unknown';
|
||||
$uploadMaxSize = ini_get('upload_max_filesize') ?: 'unknown';
|
||||
$backUrl = url()->previous() ?: url('/');
|
||||
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json([
|
||||
'message' => __('The request body is too large. Increase PHP post_max_size and upload_max_filesize (e.g. `composer run dev` or php.ini).'),
|
||||
'content_length_bytes' => $contentLength,
|
||||
'post_max_size' => $postMaxSize,
|
||||
'upload_max_filesize' => $uploadMaxSize,
|
||||
], 413);
|
||||
}
|
||||
|
||||
// ValidatePostSize runs before the web middleware group (no session yet), so a flash on redirect is often lost.
|
||||
return response()
|
||||
->view('errors.post-too-large', [
|
||||
'contentLengthMb' => $contentLengthMb,
|
||||
'postMaxSize' => $postMaxSize,
|
||||
'uploadMaxSize' => $uploadMaxSize,
|
||||
'backUrl' => $backUrl,
|
||||
], 413);
|
||||
});
|
||||
})->create();
|
||||
|
||||
Reference in New Issue
Block a user