【发布时间】:2017-07-11 09:42:57
【问题描述】:
任何人都可以帮我转换它并帮助菜鸟了解其中的区别。
/**
* 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 一起使用;
【问题讨论】:
-
错误代码按原样抛出:``` ValidatesRequests.php 第 50 行中的 FatalThrowableError:类型错误:传递给 App\Http\Controllers\Controller::validate() 的参数 1 必须是Illuminate\Http\Request,给定的 Illuminate\Support\Facades\Request 实例,在 /home/UNIT3D_2.0/app/Http/Controllers/UserController.php 的第 269 行调用```
-
您应该编辑您的问题并在此处添加错误。
标签: php laravel laravel-5 namespaces laravel-5.4