<?php

namespace App\Filament\Resources;

use App\Filament\Resources\IndustryPageResource\Pages;
use App\Filament\Resources\IndustryPageResource\RelationManagers;
use App\Models\IndustryPage;
use Filament\Forms;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Columns\ImageColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;

class IndustryPageResource extends Resource
{
    protected static ?string $model = IndustryPage::class;

    protected static ?string $navigationIcon = 'heroicon-o-home-modern';
    protected static ?string $navigationGroup = 'Industries';
    protected static ?int $navigationSort = 1;
    public static function canCreate(): bool
    {
        return IndustryPage::count() === 0;
    }
    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                Section::make()
                    ->columns(1)
                    ->schema([
                        FileUpload::make('image')
                            ->image()
                            ->disk('images')
                            ->required(),
                        TextInput::make('title')
                            ->required(),
                        TextInput::make('description')
                            ->required(),

                        TextInput::make('booking_title')
                            ->required(),
                        TextInput::make('booking_description')
                            ->required(),
                    ]),
                Section::make('Meta Data')
                    ->columns(1)
                    ->collapsed()
                    ->collapsible()
                    ->schema([

                        TextInput::make('meta_title'),
                        TextInput::make('meta_description'),
                        TextInput::make('meta_keyword'),
                    ])
            ]);
    }

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
                ImageColumn::make('image')
                    ->disk('images'),
                TextColumn::make('title')->words(3),
                TextColumn::make('description')->words(3),
            ])
            ->filters([
                //
            ])
            ->actions([
                Tables\Actions\EditAction::make(),
            ])
            ->bulkActions([
                Tables\Actions\BulkActionGroup::make([
                    Tables\Actions\DeleteBulkAction::make(),
                ]),
            ]);
    }

    public static function getRelations(): array
    {
        return [
            //
        ];
    }

    public static function getPages(): array
    {
        return [
            'index' => Pages\ListIndustryPages::route('/'),
            'create' => Pages\CreateIndustryPage::route('/create'),
            'edit' => Pages\EditIndustryPage::route('/{record}/edit'),
        ];
    }
}
