<?php

namespace App\Filament\Resources\ClientUploads\Tables;

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

class ClientUploadsTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('name')
                    ->label('Nama Mitra/Klien') 
                    ->searchable(),
                    
                ImageColumn::make('image')
                    ->label('Logo') 
                    ->disk('public'),
                    
                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_clients');
                         Cache::forget('about_page_clients');
                    }),
            ])
            ->bulkActions([
                BulkActionGroup::make([
                    DeleteBulkAction::make()
                        ->after(function () {
                            Cache::forget('home_clients');
                            Cache::forget('about_page_clients');
                      
                        }),
                ]),
            ]);
    }
}