Skip to content

Commit

Permalink
Merge pull request #31 from noxoua/develop
Browse files Browse the repository at this point in the history
improvements
  • Loading branch information
noxoua authored Nov 3, 2023
2 parents a1cea55 + c9814ed commit 66cfaa4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
13 changes: 13 additions & 0 deletions docs/004-fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ $fields->schema([

____

### Enum

```php
$fields->schema([
'status' => fn (Field $field) => $field
->enum(App\Enums\OrderStatus::class)
->label('Status'),
])
```

![Screenshot](./assets/images/enum-screenshot.png)

____

### Date & Time

Expand Down
Binary file added docs/assets/images/enum-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 11 additions & 5 deletions resources/views/components/badge.blade.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
@php
use Filament\Support\Contracts\HasColor;
use Filament\Support\Contracts\HasLabel;
use Filament\Support\Contracts\HasIcon;
@endphp

<div class="flex flex-wrap gap-2">
@if (is_string($value) || $value instanceof \UnitEnum)
@if (is_string($value) || $field->is('enum'))
@php
if (is_string($value)) {
$color = $field->badgeColor;
$label = $value;
$color = $field->badgeColor;
$icon = null;
} else {
$color = $value?->getColor() ?? $field->badgeColor;
$label = $value?->getLabel() ?? $value;
$icon = $value?->getIcon();
$label = $value instanceof HasLabel ? $value->getLabel() : $value;
$color = $value instanceof HasColor ? $value->getColor() : $field->badgeColor;
$icon = $value instanceof HasIcon ? $value->getIcon() : null;
}
@endphp

Expand Down

0 comments on commit 66cfaa4

Please sign in to comment.