AnalyticsService
in package
Service for generating analytics and reports.
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
- Initialize the analytics service.
- exportSalesReport() : string
- Export sales report as CSV content.
- getCustomerAnalytics() : array<string|int, mixed>
- Get customer analytics.
- getDashboardStats() : array<string|int, mixed>
- Get dashboard summary statistics.
- getOrderAnalytics() : array<string|int, mixed>
- Get order analytics (hourly distribution, status breakdown).
- getPopularItemsReport() : array<string|int, mixed>
- Get popular items report.
- getSalesReport() : array<string|int, mixed>
- Get sales report data.
- escapeCsv() : string
- Escape a value for CSV output.
Properties
$customerModel
private
Customer
$customerModel
Customer model
$orderModel
private
Order
$orderModel
Order model
Methods
__construct()
Initialize the analytics service.
public
__construct() : mixed
exportSalesReport()
Export sales report as CSV content.
public
exportSalesReport(int $businessId, string $startDate, string $endDate) : string
Parameters
- $businessId : int
-
Business ID
- $startDate : string
-
Start date
- $endDate : string
-
End date
Return values
string —CSV content
getCustomerAnalytics()
Get customer analytics.
public
getCustomerAnalytics(int $businessId) : array<string|int, mixed>
Parameters
- $businessId : int
-
Business ID
Return values
array<string|int, mixed>getDashboardStats()
Get dashboard summary statistics.
public
getDashboardStats(int $businessId) : array<string|int, mixed>
Parameters
- $businessId : int
-
Business ID
Return values
array<string|int, mixed>getOrderAnalytics()
Get order analytics (hourly distribution, status breakdown).
public
getOrderAnalytics(int $businessId, string $startDate, string $endDate) : array<string|int, mixed>
Parameters
- $businessId : int
-
Business ID
- $startDate : string
-
Start date
- $endDate : string
-
End date
Return values
array<string|int, mixed>getPopularItemsReport()
Get popular items report.
public
getPopularItemsReport(int $businessId[, int $limit = 10 ][, string|null $startDate = null ][, string|null $endDate = null ]) : array<string|int, mixed>
Parameters
- $businessId : int
-
Business ID
- $limit : int = 10
-
Number of items
- $startDate : string|null = null
-
Start date
- $endDate : string|null = null
-
End date
Return values
array<string|int, mixed>getSalesReport()
Get sales report data.
public
getSalesReport(int $businessId[, string $period = 'monthly' ][, string $startDate = null ][, string $endDate = null ]) : array<string|int, mixed>
Parameters
- $businessId : int
-
Business ID
- $period : string = 'monthly'
-
Period type: daily, weekly, monthly
- $startDate : string = null
-
Start date
- $endDate : string = null
-
End date
Return values
array<string|int, mixed>escapeCsv()
Escape a value for CSV output.
private
escapeCsv(string $value) : string
Parameters
- $value : string
-
Value to escape