我有一个类似的代码:
class ClassName extends BaseController implements InterfaceCrudController {
public function FunctionName() {
$error = null;
$messenge = null;
$request = Request::all();
try {
$query = DB::table("TableName")->where("Field_1", "=", $request["Field_1"])->where("Field_2", "=", $request["Field_2"]);
$query->update(array(
"Data_1" => $request["Data_1"],
"Data_2" => $request["Data_2"]
));
$error = false;
$messenge = "Success";
} catch (\Exception $e) {
$error = true;
$messenge = "Error: " . $e;
}
return Response::json(array(
"error" => $error,
"messenge" => $messenge
));
}
}
我遇到的问题是:当您运行 update()时,执行会停止并进入错误屏幕,显示“哎呀,看起来出了问题。” 我尝试了几件事,但我找不到让剧本向我显示例外的方法。
我该如何解决这个问题?
答案 0 :(得分:0)
“哎呀,看起来出事了。”如果出现错误,页面是laravel将显示的默认视图。要获得有关错误的更多信息,包括堆栈跟踪,请执行以下操作,在app / config / app.php中打开调试模式:
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => false,