The starter includes a simple stats system that pre-calculates counts and stores them in a stats table. An admin endpoint serves the data, and a scheduled command keeps it fresh.
A single StatsService defines the queries and date ranges. The stats:calculate command runs it on a schedule. Each stat is stored as a row keyed by group and a compound key (metric + range).
Stats are calculated across four date ranges:
all - total count, no date filtertoday - created today (in configured timezone)yesterday - created yesterdayday_before - created two days agoThe timezone defaults to America/New_York and is configurable via config/stats.php.
Stats are organized into groups. The command accepts a --group option to calculate only a specific group.
subscriptions - signups per plan, active subscriptions per plan and intervalbookmarks - total bookmarkscategories - total categoriestags - total tagsSubscription stats are dynamic. They auto-expand based on however many plans exist and which pricing intervals each plan has configured.
GET /admin/stats returns all stats. Pass ?group=subscriptions to filter to a single group.
Add queries to the queries() method in StatsService. Return an Eloquent builder keyed by group and metric name. The service handles date filtering and persistence automatically.