我在用户模型中有一个范围方法“ scopeUserResponse”:
public function scopeUserResponse($query,$user_id)
{
return $query->where('users.id' , $user_id)->select(
'users.id as user_id',
'users.username as user_name',
'users.first_name as user_fname',
'users.last_name as user_lname'
);
}
我正在从控制器中调用它,例如:
$userdetail = User::userResponse($user->id)->first();
它工作正常,但现在却给我错误
Method Illuminate\Database\Query\Builder::userResponse does not exist.
即使在安装Socialite之后我的关系方法也无法正常工作。