Skip to content

[13.x] Improve Collection::select generic types - #60898

Merged
taylorotwell merged 1 commit into
laravel:13.xfrom
timacdonald:select-types
Jul 27, 2026
Merged

[13.x] Improve Collection::select generic types#60898
taylorotwell merged 1 commit into
laravel:13.xfrom
timacdonald:select-types

Conversation

@timacdonald

@timacdonald timacdonald commented Jul 27, 2026

Copy link
Copy Markdown
Member

The generic types do not satisfy this method correctly and fail on the basic documented way of using it, e.g.,

$users = collect([
    ['name' => 'Taylor Otwell', 'role' => 'Developer', 'status' => 'active'],
    ['name' => 'Victoria Faith', 'role' => 'Researcher', 'status' => 'active'],
]);
 
$users->select(['name', 'role']);

The method was expecting TKey, but that would mean it is expect a key from the parent collection, e.g., 0 and / or 1, but what we really want is a key from the nested value.

I have no idea how to do that, so I'm just making it actually work and make sense, e.g., pass a list of strings.

@taylorotwell
taylorotwell merged commit 5340a3d into laravel:13.x Jul 27, 2026
26 of 55 checks passed
@GrahamCampbell GrahamCampbell changed the title Improve Collection::select generic types [13.x] Improve Collection::select generic types Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants