我正在尝试保存新记录,但得到的只是一个白页
即使是$applicant ->save()的转储和dd也不返回任何内容。
public function store(Request $request) {
try {
if (Auth::guest()) {
return redirect()->route('login');
}
$applicant = new Applicant();
$applicant->first_name = $request->get('first_name');
$applicant->middle_name = $request->get('middle_name');
$applicant->last_name = $request->get('last_name');
dump($applicant);
$applicant->save();
dd('Saved');
} catch (Exception $e) {
Log::error("Error during orders creation:" .$e>getTraceAsString());
}
}我希望记录应该被保存
发布于 2019-07-20 21:40:38
试试这个吧
public function store(Request $request){
$applicant = new Applicant;
$applicant->first_name = $request->input('first_name');
$applicant->save();
}不要忘记在您的Controller类中包含use App\Applicant模型;如果它不能解决您的问题。请在视图部分仔细检查您的表单操作帖子。
发布于 2019-07-20 22:06:03
我认为save函数不会返回任何东西。
对于数据,必须使用create方法。
发布于 2019-07-21 02:13:58
已使用保存后返回。
$申请者->save();
=> ->json()=>(‘成功’返回已成功添加数据。‘);
https://stackoverflow.com/questions/57125245
复制相似问题