fix select_array. needed for a correct format for select2

if `$data` is a `Collection` than the return format is `[{"key":["value"]}]` and not `[{"key":"value"}]`
This commit is contained in:
Thomas Rupprecht 2022-12-01 18:31:48 +01:00 committed by Igor Scheller
parent 47b80b504c
commit 37c7b876f3
1 changed files with 1 additions and 1 deletions

View File

@ -86,7 +86,7 @@ function raw_output($output = '')
function select_array($data, $key_name, $value_name)
{
if ($data instanceof Collection) {
return $data->mapToDictionary(function (BaseModel $model) use ($key_name, $value_name) {
return $data->mapWithKeys(function (BaseModel $model) use ($key_name, $value_name) {
return [$model->{$key_name} => $model->{$value_name}];
});
}