'Tạo mới', 'updated' => 'Cập nhật', 'deleted' => 'Xóa', 'restored' => 'Khôi phục', 'login' => 'Đăng nhập', 'logout' => 'Đăng xuất', ]; public function __construct(private readonly Builder $query) {} public function title(): string { return 'Lịch sử hoạt động'; } public function query(): Builder { return $this->query->latest('id'); } public function headings(): array { return [ 'ID', 'Module', 'Hành động', 'Mô tả', 'Loại người thực hiện', 'Người thực hiện', 'Đối tượng', 'ID đối tượng', 'IP', 'Thiết bị', 'Dữ liệu cũ', 'Dữ liệu mới', 'Thời gian', ]; } public function map($row): array { /** @var ActivityLog $row */ return [ $row->id, $row->log_name, self::EVENT_LABELS[$row->event] ?? $row->event, $row->description, $row->causer_type, $row->causer_name, $row->subject_type, $row->subject_id, $row->ip_address, $row->user_agent, $this->encodeValues($row->old_values), $this->encodeValues($row->new_values), $row->created_at?->format('d/m/Y H:i:s'), ]; } public function moneyColumns(): array { return []; } private function encodeValues(?array $values): ?string { if ($values === null || $values === []) { return null; } return json_encode($values, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?: null; } }