Skip to content

Commit

Permalink
Update AnnouncementResource.php
Browse files Browse the repository at this point in the history
  • Loading branch information
Rizayev authored Feb 22, 2024
1 parent 3c3d131 commit 00f96f9
Showing 1 changed file with 36 additions and 27 deletions.
63 changes: 36 additions & 27 deletions src/Resources/AnnouncementResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

use App\Models\User;
use Filament\Forms\Components\ColorPicker;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Form;
use Filament\Forms\Get;
use Filament\Resources\Resource;
Expand All @@ -29,34 +32,40 @@ public static function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name')
->minLength(5)
->required(),
TextInput::make('title')
->minLength(5)
->required(),
Textarea::make('body')
->minLength(20)
->required(),
IconPicker::make('icon'),
Select::make('color')
->options([
...collect(FilamentColor::getColors())->map(fn ($value, $key) => ucfirst($key))->toArray(),
'custom' => 'Custom',
])
->live(),
ColorPicker::make('custom_color')
->hidden(fn (Get $get) => $get('color') != 'custom')
->requiredIf('color', 'custom')
->rgb(),
Section::make()
->schema([
TextInput::make('name')
->minLength(5)
->required(),
TextInput::make('title')
->minLength(5)
->required(),
Textarea::make('body')
->minLength(20)
->required(),
IconPicker::make('icon'),
Select::make('color')
->options([
...collect(FilamentColor::getColors())->map(fn($value, $key) => ucfirst($key))->toArray(),
'custom' => 'Custom',
])
->live(),
ColorPicker::make('custom_color')
->hidden(fn(Get $get) => $get('color') != 'custom')
->requiredIf('color', 'custom')
->rgb(),

Select::make('users')
->options([
'all' => 'all',
...User::all()->pluck('name', 'id'),
])
->multiple()
->required(),
Select::make('users')
->options(User::pluck('name', 'id')->toArray())
->hidden(fn(Get $get) => $get('all_users'))
->multiple()
->required(),
])->columns(2),

Toggle::make('all_users')
->live()
->label('All users')
->default(false),
]);
}

Expand Down

0 comments on commit 00f96f9

Please sign in to comment.