4
這段代碼在幾天前工作,但我似乎已經做了一些事情導致它破壞。Laravel驗證:調用成員函數失敗()null
我有這樣的路線:
Route::post('admin/routemanagement', '[email protected]');
,看起來像這樣:
public function addRoute(Request $request) {
if(Auth::check()) {
$rules = [
'flightDep' => 'required',
'flightArr' => 'required',
'flightDepTime' => 'required',
'flightArrTime' => 'required',
];
$messages = [
'flightDep.required' => 'A departure ICAO is required',
'flightArr.required' => 'An arrival ICAO is required',
'flightDepTime.required' => 'A departure time is required',
'flightArrTime.required' => 'An arrival time is required'
];
$validator = $this->validate($request, $rules, $messages);
if($validator->fails()) {
return redirect('admin/routemanagement')->withErrors($validator)->withInput();
}
}
運行此代碼然而,當,在$validator
變量最終空出於某種原因,我得到以下:
Call to a member function fails() on null
'$ request :: all()' – aldrin27