96329/how-to-refresh-the-user-object-in-laravel
In Laravel you can do this:
$user = Auth::user();
If I do changes on items on that object, it will give me what was there before my changes. How do I refresh the object to get the latest values? I.e. To force it to get the latest values from the DB?
Hello @kartik,
You can update the cache object like this.
Auth::setUser($user);
for Example
$user = User::find(Auth::user()->id); $user->name = 'New Name'; $user->save(); Auth::setUser($user); log::error(Auth::user()->name)); // Will be 'NEW Name'
Hey, In order to identify the type of ...READ MORE
Hey @kartik, yes we can keep track of ...READ MORE
Hello @kartik, in Laravel's inbuilt auth system, the ...READ MORE
Hello @kartik, Since Laravel uses config files to ...READ MORE
Hey @kartik, First you have to go to ...READ MORE
Named route is used to give specific ...READ MORE
Hello, This is simple you just need to ...READ MORE
Hey @kartik, Named routing is another amazing feature of ...READ MORE
Hello @kartik, You can update the cache object ...READ MORE
Hello @kartik, You can get the current user's ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.