Skip to content

Commit

Permalink
handle enum values
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Apr 26, 2024
1 parent 27710b0 commit e841fe2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Fields/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Cone\Root\Fields;

use BackedEnum;
use Closure;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
Expand Down Expand Up @@ -72,6 +73,8 @@ public function resolveFormat(Request $request, Model $model): ?string

return Collection::make($value)
->map(static function (mixed $value) use ($options): string {
$value = $value instanceof BackedEnum ? $value->value : $value;

return $options[$value] ?? $value;
})
->implode(', ');
Expand Down

0 comments on commit e841fe2

Please sign in to comment.