111 lines
3.2 KiB
PHP
111 lines
3.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\OsurgAuditResource\Pages;
|
|
use App\Models\SyncLog;
|
|
use Filament\Resources\Resource;
|
|
use Morilog\Jalali\Jalalian;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
|
|
class OsurgAuditResource extends Resource
|
|
{
|
|
protected static ?string $model = SyncLog::class;
|
|
|
|
protected static bool $isGloballySearchable = false;
|
|
|
|
public static function getNavigationIcon(): \BackedEnum|string|null
|
|
{
|
|
return 'heroicon-o-clipboard-document-list';
|
|
}
|
|
|
|
public static function getNavigationGroup(): ?string
|
|
{
|
|
return __('navigation.groups.settings');
|
|
}
|
|
|
|
public static function getNavigationSort(): ?int
|
|
{
|
|
return 20;
|
|
}
|
|
|
|
public static function getNavigationLabel(): string
|
|
{
|
|
return __('navigation.osurg_audit.title');
|
|
}
|
|
|
|
public static function getModelLabel(): string
|
|
{
|
|
return __('navigation.osurg_audit.singular');
|
|
}
|
|
|
|
public static function getPluralModelLabel(): string
|
|
{
|
|
return __('navigation.osurg_audit.title');
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('id')
|
|
->label(__('sync_log.fields.id'))
|
|
->sortable(),
|
|
|
|
TextColumn::make('datetime')
|
|
->label(__('sync_log.fields.datetime'))
|
|
->sortable()
|
|
->formatStateUsing(function ($state) {
|
|
if (! $state) {
|
|
return '-';
|
|
}
|
|
try {
|
|
$date = \Carbon\Carbon::parse($state);
|
|
return Jalalian::fromCarbon($date)->format('Y/m/d - H:i');
|
|
} catch (\Exception $e) {
|
|
return $state;
|
|
}
|
|
}),
|
|
|
|
TextColumn::make('ip')
|
|
->label(__('sync_log.fields.ip'))
|
|
->searchable(),
|
|
|
|
TextColumn::make('user')
|
|
->label(__('sync_log.fields.user'))
|
|
->searchable(),
|
|
|
|
TextColumn::make('table_name')
|
|
->label(__('sync_log.fields.table_name'))
|
|
->searchable(),
|
|
|
|
TextColumn::make('action')
|
|
->label(__('sync_log.fields.action'))
|
|
->badge()
|
|
->searchable()
|
|
->color(fn (string $state): string => match ($state) {
|
|
'created' => 'success',
|
|
'updated' => 'warning',
|
|
'deleted' => 'danger',
|
|
'synced' => 'gray',
|
|
default => 'primary',
|
|
}),
|
|
|
|
TextColumn::make('record_id')
|
|
->label(__('sync_log.fields.record_id')),
|
|
])
|
|
->defaultSort('id', 'desc');
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListOsurgAudits::route('/'),
|
|
];
|
|
}
|
|
}
|