Files
ghostpizza/app/Filament/Resources/Homepages/Schemas/HomepageForm.php
2025-10-11 17:02:49 +02:00

87 lines
3.7 KiB
PHP

<?php
namespace App\Filament\Resources\Homepages\Schemas;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Builder;
use Filament\Forms\Components\Builder\Block;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
class HomepageForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->components([
Section::make()
->schema([
FileUpload::make('photo')
->image()
->imageEditor()
->disk('public')
->directory('homepage')
->label('Zdjęcie'),
FileUpload::make('photo_mobile')
->image()
->imageEditor()
->disk('public')
->directory('homepage')
->label('Zdjęcie (widoczne na telefonie)'),
FileUpload::make('photo_menu')
->image()
->imageEditor()
->disk('public')
->directory('homepage')
->label('Zdjęcie (widoczne w menu i galerii)'),
TextInput::make('title')
->label('Tytuł')
->maxLength(2048),
RichEditor::make('body')
->label('Treść')
->columnSpanFull(),
RichEditor::make('delivery')
->label('Dowóz')
->columnSpanFull(),
RichEditor::make('address')
->label('Adres')
->columnSpanFull(),
TextInput::make('widget_link')
->label('Link do widgetu (mapa google)')
->maxLength(2048),
]),
Section::make()
->schema([
Builder::make('opening_hours')
->label('Godziny otwarcia')
->addActionLabel('Dodaj dzień tygodnia')
->collapsible()
->collapsed()
->reorderable()
->blocks([
Block::make('opening_hour')
->label(function (?array $state): string {
if ($state === null) {
return 'Dzień tygodnia';
}
return $state['name'] ?? 'Dzień tygodnia';
})
->schema([
TextInput::make('name')
->label('Dzień tygodnia')
->required(),
TextInput::make('time')
->label('Godziny otwarcia')
->required(),
])
->columns(1),
])
])
])->statePath('data');
}
}