<?php

namespace App\Filament\Resources;

use App\Enums\DegreeInclinationEnum;
use App\Filament\Resources\InclinationDescriptionResource\Pages;
use App\Filament\Resources\InclinationDescriptionResource\RelationManagers;
use App\Models\InclinationDescription;
use Filament\Forms;
use Filament\Resources\Form;
use Filament\Resources\Resource;
use Filament\Resources\Table;
use Filament\Tables;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;

class InclinationDescriptionResource extends Resource
{
    protected static ?string $model = InclinationDescription::class;

    protected static ?string $navigationGroup = 'Settings';

    protected static ?string $navigationIcon = 'heroicon-o-chevron-up';

    protected static ?string $title = 'Descriptions des inclinations';

    protected static ?string $navigationLabel = 'Descriptions des inclinations';

    protected static ?string $slug = 'descriptions-des-inclinations';


    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                Forms\Components\Select::make('inclination')
                    ->required()
                    ->options(DegreeInclinationEnum::toSelectArray())
                    ->unique(ignoreRecord: true)
                    ->columnSpanFull(),
                Forms\Components\Textarea::make('description')
                    ->required()
                    ->maxLength(65535)
                    ->columnSpanFull(),
            ]);
    }

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
                Tables\Columns\TextColumn::make('inclination'),
                Tables\Columns\TextColumn::make('description'),
                Tables\Columns\TextColumn::make('created_at')
                    ->dateTime(),
                Tables\Columns\TextColumn::make('updated_at')
                    ->dateTime(),
            ])
            ->filters([
                //
            ])
            ->actions([
                Tables\Actions\EditAction::make(),
                Tables\Actions\DeleteAction::make(),
            ])
            ->bulkActions([
                Tables\Actions\DeleteBulkAction::make(),
            ]);
    }

    public static function getPages(): array
    {
        return [
            'index' => Pages\ManageInclinationDescriptions::route('/'),
        ];
    }
}
