<?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('/'),
        ];
    }
}
