1//step 1 ) create the errors/404.blade.php in view.
2
3// step 2 ) go to Handler.php and replace the render function to belwo function.
4 public function render($request, Throwable $exception)
5 {
6 if ($exception instanceof AccessDeniedHttpException) {
7 return response(view('errors.404'), 404);
8 }
9 return parent::render($request, $exception);
10 }