<?php

namespace App\Filament\Resources\Manage\Contacts;

use App\Filament\Resources\Manage\Contacts\Infolists\ContactInfolist;
use App\Filament\Resources\Manage\Contacts\Pages\ManageContacts;
use App\Filament\Resources\Manage\Contacts\Tables\ContactTable;
use App\Models\Contact;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
use UnitEnum;

class ContactResource extends Resource
{
    protected static ?string $model = Contact::class;

    protected static ?string $modelLabel = 'Kontak';

    protected static string|UnitEnum|null $navigationGroup = 'Kelola';

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

    protected static ?string $navigationLabel = 'Kontak';

    protected static ?int $navigationSort = 9;

    protected static ?string $slug = 'manage/contacts';

    public static function getNavigationBadge(): ?string
    {
        return static::getModel()::where('replied_at', null)->count();
    }

    public static function infolist(Schema $schema): Schema
    {
        return ContactInfolist::configure($schema);
    }

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

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