added subscriber profile

This commit is contained in:
Kwesi Banson
2026-09-22 22:01:37 +00:00
parent c7f93a7dc1
commit 3ece39efe3
9 changed files with 846 additions and 5 deletions

View File

@@ -77,5 +77,30 @@ class DashboardController extends Controller
return view('dashboard.details', compact('service', 'subscribers'));
}
// app/Http/Controllers/DashboardController.php
public function subscriberProfile(Request $request, $serviceId, $msisdn)
{
$service = DB::table('subscription_services')->where('id', $serviceId)->first();
if (!$service) {
abort(404, 'Service not found.');
}
// Aggregate content frequency for this specific subscriber
$contentFrequency = DB::table('unified_billing_transactions')
->where('service_id', $serviceId)
->where('msisdn', $msisdn)
->select(
'content',
DB::raw('COUNT(*) as frequency'),
DB::raw('SUM(CAST(cost AS DECIMAL(10,2))) as total_spent'),
DB::raw('MAX(transaction_date) as last_received')
)
->groupBy('content')
->orderBy('frequency', 'desc')
->paginate(10);
return view('dashboard.subscriber-profile', compact('service', 'msisdn', 'contentFrequency'));
}
}