Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Auth/Eloquent/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,11 @@ public function remove($key)

public function merge($data)
{
$this->data($this->data()->merge(collect($data)->filter(fn ($v) => $v !== null)->all()));
$merged = $this->data()
->except(['roles', 'groups'])
->merge(collect($data)->filter(fn ($v) => $v !== null)->all());

$this->data($merged->all());

return $this;
}
Expand Down
14 changes: 14 additions & 0 deletions tests/Auth/Eloquent/EloquentUserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,20 @@ public function it_does_not_save_null_values_on_the_model()
$this->assertFalse($attributes['not_null_field']);
}

#[Test]
public function merge_does_not_set_roles_and_groups_as_model_attributes()
{
$user = $this->user();

$user->merge(['name' => 'Updated Name']);

$attributes = $user->model()->getAttributes();

$this->assertArrayNotHasKey('roles', $attributes);
$this->assertArrayNotHasKey('groups', $attributes);
$this->assertEquals('Updated Name', $attributes['name']);
}

#[Test]
#[Group('passkeys')]
public function it_gets_passkeys()
Expand Down
Loading