Created
October 27, 2023 21:30
-
-
Save awcodes/0ca10c437de1bfdf03d13b19326d6aaf to your computer and use it in GitHub Desktop.
CustomFilamentBlock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Filament\Forms\Components\Builder\Block; | |
use Filament\Forms\Components\FileUpload; | |
use Filament\Forms\Components\Radio; | |
use Filament\Forms\Components\Textarea; | |
use Filament\Forms\Components\TextInput; | |
use Filament\Forms\Get; | |
use Tmx\Utils\Enums\Heroes; | |
use Tmx\Utils\Forms\Components\BlockSettings; | |
class HeroBlock | |
{ | |
public static function make(): Block | |
{ | |
return Block::make('hero') | |
->label('Hero') | |
->schema([ | |
BlockSettings::make(), | |
Radio::make('type') | |
->inline() | |
->default(Heroes::IMAGE) | |
->options(Heroes::class) | |
->live(), | |
FileUpload::make('image') | |
->visible(fn (Get $get): bool => $get('type') === Heroes::IMAGE) | |
->image(), | |
TextInput::make('cloudinary_url') | |
->visible(fn (Get $get): bool => $get('type') === Heroes::CLOUDINARY) | |
->url(), | |
Textarea::make('heading') | |
->rows(3), | |
Textarea::make('copy') | |
->rows(3), | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment