<?php

namespace App\Filament\Resources\Accounting\JournalMappings;

use App\Filament\Resources\Accounting\JournalMappings\Pages\CreateJournalMapping;
use App\Filament\Resources\Accounting\JournalMappings\Pages\EditJournalMapping;
use App\Filament\Resources\Accounting\JournalMappings\Pages\ListJournalMappings;
use App\Filament\Resources\Accounting\JournalMappings\Schemas\JournalMappingForm;
use App\Filament\Resources\Accounting\JournalMappings\Tables\JournalMappingsTable;
use App\Models\Accounting\JournalMapping;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;

class JournalMappingResource extends Resource
{
    protected static ?string $model = JournalMapping::class;

    protected static ?string $navigationLabel = null;

    protected static ?string $modelLabel = null;

    protected static ?string $pluralModelLabel = null;

    protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedLink;

    protected static ?string $recordTitleAttribute = 'transaction_type';

    protected static ?int $navigationSort = 3;

    public static function getNavigationGroup(): ?string
    {
        return __('models.Accounting');
    }

    public static function getNavigationLabel(): string
    {
        return __('models.Journal Mappings');
    }

    public static function getModelLabel(): string
    {
        return __('models.Journal Mapping');
    }

    public static function getPluralModelLabel(): string
    {
        return __('models.Journal Mappings');
    }

    public static function form(Schema $schema): Schema
    {
        return JournalMappingForm::configure($schema);
    }

    public static function table(Table $table): Table
    {
        return JournalMappingsTable::configure($table);
    }

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

    public static function getPages(): array
    {
        return [
            'index' => ListJournalMappings::route('/'),
            'create' => CreateJournalMapping::route('/create'),
            'edit' => EditJournalMapping::route('/{record}/edit'),
        ];
    }

    public static function getNavigationBadge(): ?string
    {
        return getTenantFilteredCount(static::getModel());
    }

    public static function canCreate(): bool
    {
        return true;
    }

    public static function canEdit($record): bool
    {
        return true;
    }

    public static function canDelete($record): bool
    {
        return true;
    }

    public static function canDeleteAny(): bool
    {
        return true;
    }
}
