数组到字符串转换(SQL:插入
RegisterStudent
(LRN
,dateOfBirth
,sex
,updated_at
,created_at
)值(1234, 1996-02-10,女,2017-10-26 05:30:32,2017-10-26 05:30:32))
StudentController商店内容
public function store(Request $request){
//validation
$this->validate($request, [
'LRN' => 'required|max:100',
]);
$student = New Student;
$student->LRN = $request->input('LRN');
$student->dateOfBirth = $request->input('dateOfBirth');
$student->sex = $request->input('sex');
$student->save();
return redirect()->back();
}
答案 0 :(得分:1)
更改以下内容:
$student->sex = $request->input('sex')[0];
输入似乎是一个数组,所以你需要[0]的值
或删除输入名称中的[]以在php $request->input('sex')