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
4 changes: 2 additions & 2 deletions app/Filament/Resources/PluginBundleResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ public static function table(Table $table): Table
->orWhere('email', 'like', "%{$search}%")
->limit(50)
->get()
->mapWithKeys(fn (User $user) => [$user->id => "{$user->name} ({$user->email})"])
->mapWithKeys(fn (User $user) => [$user->id => "{$user->getFilamentName()} ({$user->email})"])
->toArray();
})
->getOptionLabelUsing(fn ($value): ?string => User::find($value)?->name)
->getOptionLabelUsing(fn ($value): ?string => User::find($value)?->getFilamentName())
->required(),
])
->action(function (PluginBundle $record, array $data): void {
Expand Down
21 changes: 21 additions & 0 deletions tests/Feature/Filament/GrantBundleToUserActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,25 @@ public function test_grant_to_user_action_can_be_called_with_user_id(): void
]);
}
}

public function test_grant_to_user_action_works_for_user_with_null_name(): void
{
$recipient = User::factory()->create(['name' => null]);
$plugins = Plugin::factory()->count(1)->approved()->create();
$this->bundle->plugins()->attach($plugins->pluck('id'));

Livewire::actingAs($this->admin)
->test(ListPluginBundles::class)
->callAction(
TestAction::make('grantToUser')->table($this->bundle),
data: ['user_id' => $recipient->id],
)
->assertHasNoFormErrors();

$this->assertDatabaseHas('plugin_licenses', [
'user_id' => $recipient->id,
'plugin_id' => $plugins->first()->id,
'plugin_bundle_id' => $this->bundle->id,
]);
}
}
Loading