72 lines
2.5 KiB
PHP
72 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace Paymenter\Extensions\Others\ComplianceTools\Admin\Resources;
|
|
|
|
use Filament\Resources\Resource;
|
|
use Filament\Tables\Table;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Filters\SelectFilter;
|
|
use Paymenter\Extensions\Others\ComplianceTools\Admin\Resources\AuditLogResource\Pages\ListAuditLogs;
|
|
use Paymenter\Extensions\Others\ComplianceTools\Models\AuditLog;
|
|
|
|
class AuditLogResource extends Resource
|
|
{
|
|
protected static ?string $model = AuditLog::class;
|
|
|
|
protected static ?string $navigationIcon = 'ri-clipboard-line';
|
|
|
|
protected static ?string $activeNavigationIcon = 'ri-clipboard-fill';
|
|
|
|
protected static ?string $navigationGroup = 'Compliance';
|
|
|
|
protected static ?string $navigationLabel = 'Audit Logs';
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->defaultSort('created_at', 'desc')
|
|
->columns([
|
|
TextColumn::make('category')
|
|
->label('Category')
|
|
->sortable()
|
|
->searchable()
|
|
->badge(),
|
|
TextColumn::make('event')
|
|
->label('Event')
|
|
->sortable()
|
|
->searchable()
|
|
->badge(),
|
|
TextColumn::make('subject.name')
|
|
->label('Subject')
|
|
->sortable()
|
|
->searchable(['subject.name', 'subject.email'])
|
|
->formatStateUsing(fn (?string $state, AuditLog $record) => $state ?? $record->subject?->email),
|
|
TextColumn::make('actor_type')
|
|
->label('Actor type')
|
|
->sortable()
|
|
->formatStateUsing(fn (?string $state) => $state ? class_basename($state) : 'System'),
|
|
TextColumn::make('actor_id')
|
|
->label('Actor ID')
|
|
->sortable(),
|
|
TextColumn::make('ip_address')
|
|
->label('IP')
|
|
->sortable(),
|
|
TextColumn::make('created_at')
|
|
->label('Logged at')
|
|
->dateTime()
|
|
->sortable(),
|
|
])
|
|
->filters([
|
|
SelectFilter::make('category')
|
|
->options(fn () => AuditLog::query()->distinct()->pluck('category', 'category')->toArray()),
|
|
]);
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => ListAuditLogs::route('/'),
|
|
];
|
|
}
|
|
}
|