Skip to content
Discussion options

You must be logged in to vote

You can change the format to the following:

return Role::query()->orderBy('name')->pluck('id', 'name')->toArray();

GIven the following example:

[
    "BusinessPartner DE" => 2,
    "BusinessPartner EN" => 5,
    "BusinessPartner FR" => 12,
    "Partner France" => 12,
]

vs

[
    2 => "BusinessPartner DE",
    5 => "BusinessPartner EN",
    12 => "BusinessPartner FR",
    12 => "Partner France"
]

With labels as key, you can have multiple redundant values with different labels. Having value as the key eliminates this possibility.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@sfroemkenjw
Comment options

@crynobone
Comment options

Answer selected by crynobone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #6021 on November 06, 2023 11:48.