Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task : Update Profile Name and Email #213

Open
masehitam opened this issue Dec 21, 2022 · 1 comment
Open

Task : Update Profile Name and Email #213

masehitam opened this issue Dec 21, 2022 · 1 comment

Comments

@masehitam
Copy link

masehitam commented Dec 21, 2022

I'm curious why using
$user = User::find(auth()->user()->id);
is wrong, and
$user = auth()->user();
is right in the unit test

but if I try on browser the method doing exactly the same (Name, email, password changed succesfully)
full code

  // $user = User::find(auth()->user()->id);
  $user = auth()->user();
  $user->name = $request->input('name');
  $user->email = $request->input('email');
  // Also, update the password if it is set
  if ($request->has('password')) {
      $user->password = Hash::make($request->input('password'));
  }
  $user->save();

thanks for the help.

@selajdinbilali
Copy link

Hi I had the same issue. I dont know the answer but I think that auth() return an Authenticable and find() just an User.
And it seems to make the test happy. Thank you for your question it helped me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants