Initial commit

This commit is contained in:
2025-10-11 17:02:49 +02:00
commit 92056f073f
243 changed files with 27536 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
<?php
namespace App\Filament\Resources\Homepages;
use App\Filament\Resources\Homepages\Pages\CreateHomepage;
use App\Filament\Resources\Homepages\Pages\EditHomepage;
use App\Filament\Resources\Homepages\Pages\ListHomepages;
use App\Filament\Resources\Homepages\Pages\ViewHomepage;
use App\Filament\Resources\Homepages\Schemas\HomepageForm;
use App\Filament\Resources\Homepages\Schemas\HomepageInfolist;
use App\Filament\Resources\Homepages\Tables\HomepagesTable;
use App\Models\Homepage;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
class HomepageResource extends Resource
{
public static function canAccess(): bool
{
return auth()->user()?->can('admin') || auth()->user()?->can('manage_pizzas') ?? false;
}
protected static ?string $model = Homepage::class;
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-home';
protected static string | \UnitEnum | null $navigationGroup = 'Treść';
protected static ?string $pluralModelLabel = 'Strona główna';
protected static ?string $modelLabel = 'Strona główna';
protected static ?int $navigationSort = 1;
protected static ?string $recordTitleAttribute = 'Homepage';
public static function form(Schema $schema): Schema
{
return HomepageForm::configure($schema);
}
public static function getPages(): array
{
return [
'index' => EditHomepage::route('/'),
];
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Filament\Resources\Homepages\Pages;
use App\Filament\Resources\Homepages\HomepageResource;
use Filament\Resources\Pages\EditRecord;
class EditHomepage extends EditRecord
{
protected static string $resource = HomepageResource::class;
public function mount($record = null): void
{
$record = $record ?? 1;
parent::mount($record);
}
protected function getHeaderActions(): array
{
return [
//
];
}
}

View File

@@ -0,0 +1,86 @@
<?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');
}
}