Custom error page in Laravel

Step 1. Create a view resources\views\exceptions\404.blade.php
Step 2. Add the following code in App\Exceptions\Handler.php

/**
 * Render an exception into a response.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  \Exception  $e
 * @return \Illuminate\Http\Response
 */
public function render($request, Exception $e)
{
    if($e instanceof NotFoundHttpException)
    {
        return response()->view('exceptions.404', [], 404);
    }
    return parent::render($request, $e);
}

About the author

Janaki(http://mjanaki.com) - A Software developer with 9+ years of experience in multiple technology projects across web, mobile, and cloud applications with expertise in PHP, C#, MySQL, Web services and open source platforms.

Similar Posts

Leave a reply

required*

Eye Test: * Time limit is exhausted. Please reload CAPTCHA.