Laravel Request::input Call to undefined method

10 浏览
0 Comments

Laravel Request::input Call to undefined method

我对Laravel框架还不熟悉,现在在尝试更新登录用户信息时遇到了一个问题。

路由:

Route::post('/user/{id}', function (Request $request, $id) {
    return App\Http\Controllers\UsersController::update($request, $id);
});
public static function update($request, $id)
{
    $user = User::find($id);
    $user->name = $request->input('name');
    ...
    $user->save();
    ...
}

错误信息:

FatalErrorException in UsersController.php line 24: 调用未定义的方法 Illuminate\Support\Facades\Request::input()

0