Generate trends using Trend::model() and Trend::query()
masterTo start a trend, you must use either Trend::model() or Trend::query().
- Use
Trend::model(Model::class)when you want to perform operations on the entire model. - Use
Trend::query(Builder $query)when you need to apply additional Eloquent filters (likewhere,has, etc.) before calculating the trend.
// Using model directly
Trend::model(Order::class)
->between(...)
->perDay()
->count();
// Using a specific query with filters
Trend::query(
Order::query()
->hasBeenPaid()
->hasBeenShipped()
)
->between(...)
->perDay()
->count();