diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 20b8478d2acf..1935b0df7a9a 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -69,7 +69,9 @@ class Handler extends ExceptionHandler */ public function render($request, Exception $e) { - if ($e instanceof \Illuminate\Session\TokenMismatchException) { + if ($e instanceof ModelNotFoundException) { + return Redirect::to('/'); + } if ($e instanceof \Illuminate\Session\TokenMismatchException) { // prevent loop since the page auto-submits if ($request->path() != 'get_started') { // https://gist.github.com/jrmadsen67/bd0f9ad0ef1ed6bb594e diff --git a/app/Http/Requests/EntityRequest.php b/app/Http/Requests/EntityRequest.php index 5bed9329fcd0..88ba623d03ea 100644 --- a/app/Http/Requests/EntityRequest.php +++ b/app/Http/Requests/EntityRequest.php @@ -1,7 +1,5 @@ entityType); - try { - if (method_exists($class, 'trashed')) { $this->entity = $class::scope($publicId)->withTrashed()->firstOrFail(); } else { $this->entity = $class::scope($publicId)->firstOrFail(); } - } - catch(ModelNotFoundException $e) { - - if(Request::header('X-Ninja-Token') != '') { - - $error['error'] = ['message'=>'Entity not found']; - $error = json_encode($error, JSON_PRETTY_PRINT); - $headers = Utils::getApiHeaders(); - - return response()->make($error, 400, $headers); - - } - } - return $this->entity; }