Answers for "laravel 404 not found page"

PHP
0

laravel 404 not found not showing error

php artisan key:generate
php artisan optimize
php artisan config:cache
Posted by: Guest on November-01-2021
1

404 page in laravel

//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);
    }
Posted by: Guest on March-17-2021
1

custom 404 page in laravel

A very simple one
  
  php artisan vendor:publish --tag=laravel-errors
Posted by: Guest on July-02-2021
0

show 500 or 404 page in laravel

public function render($request, Exception $e)
{

    // 404 page when a model is not found
    if ($e instanceof ModelNotFoundException) {
        return response()->view('errors.404', [], 404);
    }

    if ($this->isHttpException($e)) {
        return $this->renderHttpException($e);
    } else {
        // Custom error 500 view on production
        if (app()->environment() == 'production') {
            return response()->view('errors.500', [], 500);
        }
        return parent::render($request, $e);
    }

}
Posted by: Guest on July-09-2020
0

how to set 404 page in laravel

/**
 * Render an exception into an HTTP response.
 *
 * @param  IlluminateHttpRequest  $request
 * @param  Exception  $exception
 * @return IlluminateHttpResponse
 */
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);
}
Posted by: Guest on March-03-2021

Code answers related to "laravel 404 not found page"

Browse Popular Code Answers by Language