'Bạn', 'admin' => 'Nhân viên hỗ trợ', 'system' => 'Tự động gia hạn', ]; public function __invoke(Request $request, string $uuid): JsonResponse { $service = Service::where('uuid', $uuid)->where('customer_id', $request->user()->id)->firstOrFail(); $items = ActivityLog::where('subject_type', Service::class) ->where('subject_id', $service->id) ->where('event', 'renewed') ->latest('id') ->limit(100) ->get(['causer_type', 'old_values', 'new_values', 'created_at']) ->map(fn (ActivityLog $log) => [ 'renewed_at' => $log->created_at?->toISOString(), 'months' => (int) ($log->new_values['months'] ?? 0), 'amount' => (int) ($log->new_values['amount'] ?? 0), 'invoice_number' => $log->new_values['invoice_number'] ?? null, 'paid_by' => ($log->new_values['payment_method'] ?? null) === 'balance' ? 'Số dư tài khoản' : 'Thanh toán khác', 'old_expires_at' => $log->old_values['expires_at'] ?? null, 'new_expires_at' => $log->new_values['expires_at'] ?? null, 'by' => self::CAUSER_LABELS[$log->causer_type] ?? self::CAUSER_LABELS['system'], ]) ->values(); return response()->json(['error' => false, 'data' => $items]); } }