I'm trying to force an authentication without login with Laravel 5.7 like that:
public function login()
{
$cpf = Request::only('cpf');
$user = new User;
$user = $user->where('cpf', $cpf)->get();
Auth::loginUsingId($user->id);
return redirect('/perfil');
}
And I get this error: Property [id] does not exist on this collection instance.
When I debug the model User, all the attributes are there. But when I try to get the attributes, I get this error. What I'm doing wrong?
If there's any other way to authenticate without password, It would be helpful!