Replies: 1 comment
-
I use Source: https://stackoverflow.com/questions/64656614/getting-an-id-from-laravel-command-choice
Hope it helps |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Laravel Version
11
PHP Version
8.3
Database Driver & Version
No response
Description
I'm experiencing an unusual behavior with the choice() method of the Command class in Laravel. As per Laravel's documentation, when using choice() with an associative array, it should return the value for a selected option. However, in my case, it's returning the key from the array.
Here's a code sample illustrating this:
In this case, $case->label() is a long text and $case->value is a number so the $regimenFiscalList array is built with long text as the key and number as the value.
When an option is selected via the $this->choice() call, the returned value is the long text (the array's key), not the number (the value).
Any assistance looking into this issue would be much appreciated.
Steps To Reproduce
Beta Was this translation helpful? Give feedback.
All reactions