Product Decisions This Supports
- Time-based analytics & reporting: Accelerates development of dashboards, KPIs, or financial reports requiring granular date ranges (e.g., "revenue last 7 days," "user activity this quarter").
- Build vs. Buy: Eliminates custom query logic for common date scopes, reducing dev time and technical debt. Avoids reinventing wheel for inclusive/exclusive date ranges.
- Roadmap prioritization: Enables rapid iteration on time-series features (e.g., A/B testing by time periods, cohort analysis) without blocking on backend work.
- Use cases:
- E-commerce: "Sales this month vs. last month."
- SaaS: "Churn rate last 30 days."
- Logistics: "Deliveries in the last 24 hours."
- Healthcare: "Patient visits this quarter."
When to Consider This Package
-
Adopt if:
- Your Laravel app heavily relies on time-based queries (e.g., analytics, reporting).
- You need consistent, reusable date scopes across multiple models (e.g.,
User, Order, Log).
- Your team lacks dedicated backend resources to build/maintain custom date logic.
- You require flexibility for inclusive/exclusive ranges or custom columns (e.g.,
published_at instead of created_at).
- You’re using Laravel 10+ (confirmed compatibility).
-
Look elsewhere if:
- You need advanced time zones or recurring intervals (e.g., "every Monday at 9 AM").
- Your queries involve complex joins where date scopes would require significant customization.
- You’re using a non-Laravel framework or need multi-database support.
- You require real-time streaming of time-based data (this is for batch queries).
- Your team prefers raw SQL or ORM-agnostic solutions (e.g., PostgreSQL’s
date_trunc).
How to Pitch It (Stakeholders)
For Executives:
"This package cuts 30–50% of the dev time needed to build time-based analytics features. For example, instead of writing custom queries for ‘revenue last 7 days’ or ‘user activity this month,’ our team can reuse pre-built, battle-tested scopes. It’s like adding a ‘date filter’ superpower to our Eloquent models—consistent, maintainable, and scalable. The MIT license means no vendor lock-in, and it’s already used by 500+ projects. Let’s adopt this to ship features faster."
For Engineering:
*"This is a drop-in trait that adds 30+ reusable date scopes to Eloquent models (e.g., Model::ofLastWeek(), Model::monthToDate()). Key benefits:
- No custom query logic: Eliminates repetitive
whereBetween() calls.
- Configurable: Toggle inclusive/exclusive ranges globally or per-query (e.g.,
ofLast7Days(customRange: DateRange::INCLUSIVE)).
- Flexible: Works with any date column (e.g.,
approved_at, published_at).
- Laravel 10+ ready: Actively maintained with 500+ stars.
- Zero performance overhead: Just adds query constraints.
Example win:
// Before (custom code):
Order::where('created_at', '>=', now()->subDays(7))->where('created_at', '<', now());
// After (with package):
Order::ofLast7Days()->sum('amount'); // Clean, reusable, and chainable.
Ask: Should we standardize this across all time-based queries in the app?"*