<?php

namespace App\Filament\Resources;

use App\Filament\Resources\UniPopUpResource\Pages;
use App\Models\UniPopUp;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;

class UniPopUpResource extends Resource
{
    protected static ?string $model = UniPopUp::class;
    protected static ?string $navigationIcon = 'heroicon-o-bolt';
    protected static ?string $navigationLabel = 'Special Pop Up';
    protected static ?string $pluralLabel = 'Special Pop Up';
    protected static ?string $modelLabel = 'Special Pop Up';
    protected static ?string $navigationGroup = 'Content Management';

    public static function form(Form $form): Form
    {
        return $form->schema([
            Forms\Components\TextInput::make('title')->required()->maxLength(255),
            Forms\Components\TextInput::make('number_off')->numeric()->nullable(),
            Forms\Components\TextInput::make('sign')->maxLength(50)->nullable(),
            Forms\Components\TextInput::make('off')->maxLength(50)->nullable(),
            Forms\Components\Textarea::make('desc')->nullable(),
            Forms\Components\Toggle::make('status')->label('Active'),
            Forms\Components\TextInput::make('url')->url()->nullable(),
        ]);
    }

    public static function table(Table $table): Table
    {
        return $table->columns([
            Tables\Columns\TextColumn::make('title')->sortable()->searchable(),
            Tables\Columns\TextColumn::make('number_off'),
            Tables\Columns\TextColumn::make('sign'),
            Tables\Columns\TextColumn::make('off'),
            Tables\Columns\TextColumn::make('desc')->limit(30),
            Tables\Columns\IconColumn::make('status')->boolean()->label('Active'),
            Tables\Columns\TextColumn::make('url')->limit(30),
            Tables\Columns\TextColumn::make('created_at')->dateTime()->sortable(),
        ])
        ->actions([
            Tables\Actions\EditAction::make(),
            Tables\Actions\DeleteAction::make(),
        ])
        ->bulkActions([
            Tables\Actions\BulkActionGroup::make([
                Tables\Actions\DeleteBulkAction::make(),
            ]),
        ]);
    }

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

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