Hey guys I'm testing some model relationsships and I'm curious if I can refactor my code a bit.
// Assign User a role $user->role()->save($admin); // Role should be admin $this->assertEquals('admin', $user->role->name); // Change Users Role $user->role()->updateExistingPivot($admin->id, ['role_id' => $manager->id]); // Reload User $user = User::find(1);
At the end it seems I have to run a new query to get the updated relationship. Is there anyway to do something like this...
// Reload User $user->reload();
// Reload User $user->refresh();
... get updated info after a save? It seems like if I'm using the same ID and everything I shouldn't have to create a new Model instance but maybe this is an instance where I should look into extending the framework for my edge case.