任何人都可以幫助我轉換這個,並幫助菜鳥學習差異。Laravel請求轉換
/**
* User Delete Account via Profile
*
* @access protected
* @return void
*
*/
protected function deleteProfile(Request $request) {
$this->validate($request, [
'confirmation' => 'required',
'password' => 'required',
]);
$usr = User::findOrFail(Auth::user()->id);
if (Hash::check($request->password, $usr->password)) {
Auth::logout();
// Removes UserID from Torrents if any and replaces with System UserID (0)
foreach(Torrent::where('user_id', '=', $usr->id)->get() as $tor) {
$tor->user_id = 0;
$tor->save();
}
// Removes UserID from Comments if any and replaces with System UserID (0)
foreach(Comment::where('user_id', '=', $usr->id)->get() as $com) {
$com->user_id = 0;
$com->save();
}
if($usr->delete()) {
return view('members.delete_account');
}
} else {
return redirect()->back()->with(Toastr::warning('Your Password Was Incorrect!', 'Error', ['options']));
}
}
設置爲使用Illuminate \ Http \ Request;
但我需要它與Illuminate \ Support \ Facades \ Request一起工作;
誤差代碼拋出是: ''' FatalThrowableError在ValidatesRequests.php管線50: 類型錯誤:參數1傳遞給應用程序\ HTTP \控制器\控制器::驗證( )必須是Illuminate \ Http \ Request的實例,在給定的Illuminate \ Support \ Facades \ Request的實例中,在269行中調用/home/UNIT3D_2.0/app/Http/Controllers/UserController.php –
應該編輯你的問題並在那裏添加錯誤。 – Samsquanch