PHP code example of arielmejiadev / inertiajs-error-page
1. Go to this page and download the library: Download arielmejiadev/inertiajs-error-page library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
arielmejiadev / inertiajs-error-page example snippets
php artisan vendor:publish --tag=inertiajs-errors
php
public function render($request, Throwable $exception)
{
$response = parent::render($request, $exception);
if ($this->thereAreErrorsInProduction($response)) {
return \Inertia\Inertia::render('Errors/Error', [
'status' => $response->status(),
'message' => $exception->getMessage(),
'home' => config('app.url'),
])->toResponse($request)->setStatusCode($response->status());
} else if ($response->status() === 419) {
return back()->with([
'message' => 'The page expired, please try again.',
]);
}
return $response;
}
public function thereAreErrorsInProduction($response)
{
return \Illuminate\Support\Facades\App::environment('production') && in_array($response->status(), [500, 503, 404, 403, 401, 429]);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.