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 }
1/**
2 * Render an exception into an HTTP response.
3 *
4 * @param \Illuminate\Http\Request $request
5 * @param \Exception $exception
6 * @return \Illuminate\Http\Response
7 */
8public function render($request, Exception $exception)
9{
10 if ($this->isHttpException($exception)) {
11 if ($exception->getStatusCode() == 404) {
12 return response()->view('errors.' . '404', [], 404);
13 }
14 }
15
16 return parent::render($request, $exception);
17}
18