ldc-legaulois/app/Exceptions/Handler.php
2022-02-10 16:14:58 +01:00

44 lines
1.2 KiB
PHP

<?php
namespace App\Exceptions;
use Illuminate\Session\TokenMismatchException;
use Kwaadpepper\ExceptionHandler\Exceptions\ExceptionHandler;
use Symfony\Component\Console\Exception\CommandNotFoundException;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
RedirectTo::class,
CommandNotFoundException::class
];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];
public function render($request, Throwable $e)
{
// redirect to connection if user is in BO and session timeout
if ($request->is('bo', 'bo/*') and \get_class($e) === TokenMismatchException::class) {
if (\in_array('GET', $request->route()->methods)) {
return \redirect()->route($request->route()->getName());
} else {
return \redirect()->route('bo.dashboard');
}
}
return parent::render($request, $e);
}
}