我认为这只是一个小问题,但我似乎找不到它出现语法错误的原因..我已经提到laravel的网站了,而且我正在寻找一个而现在。 (我还是新手。对不起)
它说FatalErrorException 语法错误,意外'(' 在LoginController.php中(第134行)
以下代码
public function updateUser(Request $request)
{
//line 134 is here
User::('users')->where('user_id', session('userSocial')['id'])->update(["address" => "input['users-city']"]);
User::('users')->where('user_id', session('userSocial')['id'])->update(["contact" => "input['users-contact']"]);
User::('users')->where('user_id', session('userSocial')['id'])->update(["email" => "users-email"]);
}
答案 0 :(得分:1)
您的语法适用于DB
构建器:
DB::table('users')->where('user_id', session('userSocial')['id'])->update(["address" => $request->userscity]);
DB::table('users')->where('user_id', session('userSocial')['id'])->update(["contact" => $request->userscontact]);
DB::table('users')->where('user_id', session('userSocial')['id'])->update(["email" => $request->usersemail]);
您可以在一个查询中重新组合更新以进行优化:
DB::table('users')->where('user_id', session('userSocial')['id'])
->update([
"address" => $request->userscity,
"contact" => $request->userscontact,
"email" => $request->usersemail]
);
或者您可以使用Eloquent
:
User::where('user_id', session('userSocial')['id'])
->update([
"address" => $request->userscity,
"contact" => $request->userscontact,
"email" => $request->usersemail]
);
答案 1 :(得分:1)
User::where('user_id',\Session::get('userSocial')['id'])
->update(["address" => $request->users-city]);
User::where('user_id', \Session::get('userSocial')['userSocial']
->update(["contact" => $request->users-contact]);
User::where('user_id', \Session::get('userSocial')['userSocial']
->update(["email" => $request->users-email]);
答案 2 :(得分:0)
我想你可以试试这个:
public function updateUser(Request $request){
User::where('user_id', session('userSocial')['id'])->update(["address" => "input['users-city']"]);
User::where('user_id', session('userSocial')['id'])->update(["contact" => "input['users-contact']"]);
User::where('user_id', session('userSocial')['id'])->update(["email" => "users-email"]);
}
希望这对你有用!!!