<?php

namespace App\Filament\Resources\Cities\Tables;

use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\DeleteAction;
use Filament\Actions\EditAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Support\Facades\Cache;

class CitiesTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('province.name')
                    ->label('Provinsi Induk') 
                    ->sortable(),
                TextColumn::make('region_code')
                    ->label('Kode Wilayah') 
                    ->searchable(),
                TextColumn::make('name')
                    ->label('Nama Kota/Kabupaten') 
                    ->searchable(),
                TextColumn::make('creator.name')
                    ->label('Dibuat Oleh') 
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
                TextColumn::make('editor.name')
                    ->label('Diubah Oleh') 
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
                TextColumn::make('created_at')
                    ->label('Dibuat Pada') 
                    ->dateTime()
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
                TextColumn::make('updated_at')
                    ->label('Diubah Pada') 
                    ->dateTime()
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
            ])
            ->filters([
                //
            ])
          ->actions([
                EditAction::make(),
                DeleteAction::make()
                    ->after(function () {
                        Cache::forget('home_origins');
                    }),
            ])
           ->bulkActions([
                BulkActionGroup::make([
                    DeleteBulkAction::make()
                        ->after(function () {
                            Cache::forget('home_origins');
                      
                        }),
                ]),
            ]);
    }
}