捕獲應用程式範圍的 ModelNotFoundException

應用程式\ \異常 Handler.php

public function render($request, Exception $exception)
{
    if ($exception instanceof ModelNotFoundException) {
        abort(404);
    }

    return parent::render($request, $exception);
}

你可以捕獲/處理 Laravel 中丟擲的任何異常。