Answers for "404 http code laravel"

PHP
1

php create 404 error

<?php
http_response_code(404);
include('my_404.php'); // provide your own HTML for the error page
die();
Posted by: Guest on May-24-2020
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

Browse Popular Code Answers by Language