76 lines
2.5 KiB
PHP
76 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Pages\Settings;
|
|
|
|
use App\Services\ActivityLogService;
|
|
use BackedEnum;
|
|
use Filament\Pages\Page;
|
|
use Filament\Schemas\Components\EmbeddedTable;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Support\Enums\FontWeight;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Concerns\InteractsWithTable;
|
|
use Filament\Tables\Contracts\HasTable;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Contracts\Support\Htmlable;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use UnitEnum;
|
|
|
|
class ActivityLogs extends Page implements HasTable
|
|
{
|
|
use InteractsWithTable;
|
|
|
|
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-list-bullet';
|
|
|
|
protected static string|UnitEnum|null $navigationGroup = 'Pengaturan';
|
|
|
|
protected static ?int $navigationSort = 1;
|
|
|
|
protected static ?string $navigationLabel = 'Log Aktivitas';
|
|
|
|
protected static ?string $slug = 'settings/activity-logs';
|
|
|
|
protected string $view = 'filament.pages.blank';
|
|
|
|
public function getTitle(): string|Htmlable
|
|
{
|
|
return 'Log Aktivitas';
|
|
}
|
|
|
|
public static function canAccess(): bool
|
|
{
|
|
return Gate::check('view-activity-logs');
|
|
}
|
|
|
|
public function table(Table $table): Table
|
|
{
|
|
/** @var ActivityLogService $service */
|
|
$service = app(ActivityLogService::class);
|
|
|
|
return $table
|
|
->records(fn (?string $search, ?string $sortColumn, ?string $sortDirection, int|string $page, int|string $recordsPerPage) => $service->paginate(
|
|
search: $search,
|
|
sortColumn: $sortColumn,
|
|
sortDirection: $sortDirection,
|
|
page: (int) $page,
|
|
perPage: (int) $recordsPerPage,
|
|
))
|
|
->columns([
|
|
TextColumn::make('created_at')->label('Waktu')->dateTime('d M Y H:i:s', 'Asia/Jakarta')->sortable(),
|
|
TextColumn::make('user_name')->label('User')->state(fn (array $record): string => data_get($record, 'users.name', substr((string) ($record['user_id'] ?? ''), 0, 8) ?: 'sistem')),
|
|
TextColumn::make('action')->label('Aksi')->badge()->color('info'),
|
|
TextColumn::make('entity_type')->label('Entitas')->badge(),
|
|
TextColumn::make('description')->label('Deskripsi')->weight(FontWeight::Medium),
|
|
])
|
|
->paginated([10, 25, 50]);
|
|
}
|
|
|
|
public function content(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
EmbeddedTable::make(),
|
|
]);
|
|
}
|
|
}
|