数据库代码问题
public function store(Request $request)
{
$this->validate($request, [
'Schedule Name' => 'required'
]);
$schedule = new menu;
$schedule->scheduleName = $request->input('Schedule Name');
$schedule->days = $request->input('Days');
$schedule->start_time = $request->input('Start Time');
$schedule->end_time = $request->input('End Time');
$schedule->save();
return view('welcome')->with('success', 'Done');
}
答案 0 :(得分:0)
尝试使用此方法更改您的表单名称
use Validator;
public function store(Request $request)
{
$this->validate($request, [
'Schedule Name' => 'required'
]);
$schedule = new Menu;
$schedule->scheduleName = $request->input('scheduleName ');
$schedule->days = $request->input('days ');
$schedule->start_time = $request->input('start_time ');
$schedule->end_time = $request->input('end_time ');
$schedule->save();
return view('welcome')->with('success', 'Done');
}
答案 1 :(得分:0)
我在代码中看到两个问题。
$ schedule =新菜单; //型号名称应大写
所有输入字段均不得包含空格。
答案 2 :(得分:-1)
签出以下控制器方法:
use App\Menu;
public function store(Request $request)
{
$this->validate($request, [
'Schedule Name' => 'required'
]);
$schedule = new Menu; //use camel case Menu in you model and table likes menus.
$schedule->scheduleName = $request->input('Schedule Name');
$schedule->days = $request->input('Days');
$schedule->start_time = $request->input('Start Time');
$schedule->end_time = $request->input('End Time');
$schedule->save();
return view('welcome')->with('success', 'Done');
}