<?php

namespace App\Filament\Resources;

use App\Filament\Resources\AduanResource\Pages;
use App\Filament\Resources\AduanResource\Pages\CreateAduan;
use App\Filament\Resources\AduanResource\Pages\EditAduan;
use App\Filament\Resources\AduanResource\Pages\ListAduans;
use App\Filament\Resources\AduanResource\Schemas\AduanForm;
use App\Filament\Resources\AduanResource\Tables\AduansTable;
use App\Models\Aduan;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;

class AduanResource extends Resource
{
    protected static ?string $model = Aduan::class;

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

    protected static ?string $navigationLabel = 'Aduan Aktif';

    protected static ?string $recordTitleAttribute = 'isi_aduan';

    // 🔥 HANYA ADUAN AKTIF
    public static function getEloquentQuery(): Builder
    {
        return parent::getEloquentQuery()
            ->whereIn('status', ['menunggu', 'diproses']);
    }

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

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

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

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