added subscriber profile
This commit is contained in:
@@ -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'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user