AnalyticsController
extends AbstractController
in package
Sales analytics controller.
Produces detailed views of revenue and sales volumes, broken down by category, sub-category and product, with the data ready to be displayed as charts.
Attributes
- #[IsGranted]
- 'IS_AUTHENTICATED_FULLY'
Table of Contents
Methods
- category() : Response
- Detailed analysis of a category: sales evolution and breakdown across its sub-categories.
- index() : Response
- Analytics overview (global indicators and aggregated charts) for the current point of sale.
- product() : Response
- Detailed analysis of a product: sales history and performance indicators over the selected period.
- subcategory() : Response
- Detailed analysis of a sub-category: sales over time and breakdown across the products it contains.
- resolvePeriodBounds() : DateTimeImmutable, 2: string}
- Computes the date bounds matching the requested period.
- resolvePreviousPeriodBounds() : DateTimeImmutable}
- Derives the bounds of the previous period, with the same duration as the current period, in order to compute variations (period N vs N-1 comparison).
Methods
category()
Detailed analysis of a category: sales evolution and breakdown across its sub-categories.
public
category(EntityManagerInterface $entityManager, Request $request, int $id) : Response
Parameters
- $entityManager : EntityManagerInterface
- $request : Request
- $id : int
-
Identifier of the analyzed category.
Tags
Attributes
- #[Route]
- '/analytics/category/{id}'
- $name: 'analytics.category'
- $requirements: ['id' => '\d+']
Return values
Responseindex()
Analytics overview (global indicators and aggregated charts) for the current point of sale.
public
index(EntityManagerInterface $entityManager, Request $request) : Response
Parameters
- $entityManager : EntityManagerInterface
- $request : Request
Tags
Attributes
- #[Route]
- '/analytics'
- $name: 'analytics.index'
Return values
Responseproduct()
Detailed analysis of a product: sales history and performance indicators over the selected period.
public
product(EntityManagerInterface $entityManager, Request $request, int $id) : Response
Parameters
- $entityManager : EntityManagerInterface
- $request : Request
- $id : int
-
Identifier of the analyzed product.
Attributes
- #[Route]
- '/analytics/product/{id}'
- $name: 'analytics.product'
- $requirements: ['id' => '\d+']
Return values
Responsesubcategory()
Detailed analysis of a sub-category: sales over time and breakdown across the products it contains.
public
subcategory(EntityManagerInterface $entityManager, Request $request, int $id) : Response
Parameters
- $entityManager : EntityManagerInterface
- $request : Request
- $id : int
-
Identifier of the analyzed sub-category.
Tags
Attributes
- #[Route]
- '/analytics/subcategory/{id}'
- $name: 'analytics.subcategory'
- $requirements: ['id' => '\d+']
Return values
ResponseresolvePeriodBounds()
Computes the date bounds matching the requested period.
private
resolvePeriodBounds(string $period, Request $request, DateTimeImmutable $now) : DateTimeImmutable, 2: string}
Accepts "day", "week", "month", "year" or "custom" (with startDate/endDate as query parameters); any invalid value falls back to the current month.
Parameters
- $period : string
-
Requested period.
- $request : Request
-
Request carrying the optional custom dates.
- $now : DateTimeImmutable
-
Reference instant.
Return values
DateTimeImmutable, 2: string} —Inclusive start, exclusive end and resolved period.
resolvePreviousPeriodBounds()
Derives the bounds of the previous period, with the same duration as the current period, in order to compute variations (period N vs N-1 comparison).
private
resolvePreviousPeriodBounds(DateTimeImmutable $startInclusive, DateTimeImmutable $endExclusive) : DateTimeImmutable}
Parameters
- $startInclusive : DateTimeImmutable
-
Inclusive start of the current period.
- $endExclusive : DateTimeImmutable
-
Exclusive end of the current period.
Return values
DateTimeImmutable} —Inclusive start and exclusive end of the previous period.