For Period
To calculate metrics for a specific period (e.g. the result of date math), you can use the ->period($period) method.
The period value should either be a \Beacon\Metrics\Enums\Period enum value, or a DatePeriod-like instance (e.g. \Carbon\CarbonPeriod).
php
use App\Models\MyModel;
use Beacon\Metrics\Metrics;
use Carbon\CarbonPeriod;
$period = CarbonPeriod::between('2025-01-01', '2025-01-31');
$metrics = Metrics::query(MyModel::query())
->period($period)
->...Possible \Beacon\Metrics\Enums\Period values are:
Period::LAST_10_MINUTESPeriod::LAST_12_HOURSPeriod::LAST_15_MINUTESPeriod::LAST_24_HOURSPeriod::LAST_2_HOURSPeriod::LAST_30_DAYSPeriod::LAST_30_DAYS_INCLUDING_TODAYPeriod::LAST_30_MINUTESPeriod::LAST_365_DAYSPeriod::LAST_365_DAYS_INCLUDING_TODAYPeriod::LAST_5_MINUTESPeriod::LAST_60_DAYSPeriod::LAST_60_DAYS_INCLUDING_TODAYPeriod::LAST_6_HOURSPeriod::LAST_7_DAYSPeriod::LAST_7_DAYS_INCLUDING_TODAYPeriod::LAST_90_DAYSPeriod::LAST_90_DAYS_INCLUDING_TODAYPeriod::LAST_HOURPeriod::LAST_MINUTEPeriod::LAST_THIRTY_SECONDSPeriod::MONTH_TO_DATEPeriod::PREVIOUS_HOURPeriod::PREVIOUS_MINUTEPeriod::PREVIOUS_MONTHPeriod::PREVIOUS_YEARPeriod::TODAYPeriod::YEAR_TO_DATEPeriod::YESTERDAY