404 page in laravel

PHP
//step 1 ) create the errors/404.blade.php in view.

// step 2 ) go to Handler.php and replace the render function to belwo function.
  public function render($request, Throwable $exception)
    {
        if ($exception instanceof AccessDeniedHttpException) {
            return response(view('errors.404'), 404);
        }
        return parent::render($request, $exception);
    }/**
 * Render an exception into an HTTP response.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  \Exception  $exception
 * @return \Illuminate\Http\Response
 */
public function render($request, Exception $exception)
{
    if ($this->isHttpException($exception)) {
        if ($exception->getStatusCode() == 404) {
            return response()->view('errors.' . '404', [], 404);
        }
    }
 
    return parent::render($request, $exception);
}

Source

Also in PHP: