From 4688100ca0fcc707c2e37f7a326391fa557b4a33 Mon Sep 17 00:00:00 2001 From: Joshua Blum Date: Mon, 25 May 2026 14:46:29 +0200 Subject: [PATCH 1/3] Correctly resolve `default: current` --- src/Fieldtypes/Users.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Fieldtypes/Users.php b/src/Fieldtypes/Users.php index 09157cad83..298771dc76 100644 --- a/src/Fieldtypes/Users.php +++ b/src/Fieldtypes/Users.php @@ -254,7 +254,11 @@ public function augment($values) { $single = $this->config('max_items') === 1; - $ids = Arr::wrap($values); + $ids = collect(Arr::wrap($values)) + ->map(fn ($id) => $id === 'current' ? User::current()?->id() : $id) + ->filter() + ->values() + ->all(); $query = (new OrderedQueryBuilder(User::query(), $ids))->whereIn('id', $ids); From d0d3d378b8075ac1f3c7531092576736a249d773 Mon Sep 17 00:00:00 2001 From: Joshua Blum Date: Mon, 25 May 2026 14:50:26 +0200 Subject: [PATCH 2/3] Add test --- tests/Fieldtypes/UsersTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/Fieldtypes/UsersTest.php b/tests/Fieldtypes/UsersTest.php index 6539c4b6e2..73cbf6ce80 100644 --- a/tests/Fieldtypes/UsersTest.php +++ b/tests/Fieldtypes/UsersTest.php @@ -60,6 +60,17 @@ public function it_augments_to_a_single_user_when_max_items_is_one() $this->assertEquals('one@domain.com', $augmented->email()); } + #[Test] + public function it_augments_the_current_user_when_value_is_the_current_string() + { + $this->actingAs(Facades\User::find('123')); + + $augmented = $this->fieldtype(['max_items' => 1])->augment('current'); + + $this->assertInstanceOf(User::class, $augmented); + $this->assertEquals('123', $augmented->id()); + } + #[Test] public function it_shallow_augments_to_a_collection_of_users() { From 04a55a01c45035bdad91abd3fbf3f3cc8b15b330 Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Tue, 26 May 2026 11:15:58 -0400 Subject: [PATCH 3/3] more tests --- tests/Fieldtypes/UsersTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/Fieldtypes/UsersTest.php b/tests/Fieldtypes/UsersTest.php index 73cbf6ce80..6295e440f6 100644 --- a/tests/Fieldtypes/UsersTest.php +++ b/tests/Fieldtypes/UsersTest.php @@ -71,6 +71,25 @@ public function it_augments_the_current_user_when_value_is_the_current_string() $this->assertEquals('123', $augmented->id()); } + #[Test] + public function it_augments_the_current_user_to_a_query_builder_when_value_is_the_current_string() + { + $this->actingAs(Facades\User::find('123')); + + $augmented = $this->fieldtype()->augment('current'); + + $this->assertInstanceOf(Builder::class, $augmented); + $this->assertEquals(['123'], $augmented->get()->map->id()->all()); + } + + #[Test] + public function it_augments_to_null_when_value_is_the_current_string_and_no_user_is_authenticated() + { + $augmented = $this->fieldtype(['max_items' => 1])->augment('current'); + + $this->assertNull($augmented); + } + #[Test] public function it_shallow_augments_to_a_collection_of_users() {