Skip to content

Instantly share code, notes, and snippets.

@awcodes
Created October 27, 2023 21:30
Show Gist options
  • Save awcodes/0ca10c437de1bfdf03d13b19326d6aaf to your computer and use it in GitHub Desktop.
Save awcodes/0ca10c437de1bfdf03d13b19326d6aaf to your computer and use it in GitHub Desktop.
CustomFilamentBlock
<?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