---
title: "Enums — Plausible for Laravel | Roundly"
description: "Type-safe metrics, periods, intervals, properties, dimensions, operators and goal types, with enums-for-laravel helpers."
url: https://roundly-consulting.com/open-source/docs/plausible-for-laravel/enums
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Plausible for Laravel](https://roundly-consulting.com/open-source/docs/plausible-for-laravel.md)

# Enums

Type-safe, discoverable parameters live under RoundlyConsulting\\Plausible\\Enums. Anywhere an enum is accepted, the equivalent string still works:

| Enum | Used by | Values |
| --- | --- | --- |
| `Metric` | metrics() on every terminal | visitors, visits, pageviews, views\_per\_visit, bounce\_rate, visit\_duration, events, scroll\_depth, conversion\_rate, group\_conversion\_rate, total\_revenue, average\_revenue, time\_on\_page, exit\_rate, percentage |
| `Period` | period() and the v2 date range | day, 7d, 30d, month, 6mo, 12mo, year, all, custom — all is run() only |
| `Interval` | interval() for timeseries and breakdowns | minute, hour, date, week, month — v1 timeseries() takes date and month only |
| `Property` | v1 breakdown(), property(), cursor() | event:name, event:page, event:hostname, event:goal, visit:source, visit:referrer, visit:utm\_medium, visit:utm\_source, visit:utm\_campaign, visit:utm\_content, visit:utm\_term, visit:device, visit:browser, visit:browser\_version, visit:os, visit:os\_version, visit:country, visit:region, visit:city, visit:entry\_page, visit:exit\_page |
| `Dimension` | v2 dimensions() and where() | every Property value, plus visit:channel and the time:hour, time:day, time:week, time:month buckets |
| `FilterOperator` | where() / orWhere() | is, is\_not, contains, contains\_not, matches, matches\_not, and, or, not, has\_done, has\_not\_done |
| `GoalType` | CreateGoalRequest | event, page |

For a custom event property use Property::custom('plan') or Dimension::custom('plan'), which return the event:props:plan string.

## Helpers

Via enums-for-laravel every enum carries the Helpers surface — values(), labels(), options(), toOptions(), validationRule(), name and label lookups, and the is()/when\* helpers. Handy for dashboards, pickers and validating a chosen parameter:

```php
use RoundlyConsulting\Plausible\Enums\Dimension;
use RoundlyConsulting\Plausible\Enums\Metric;
use RoundlyConsulting\Plausible\Enums\Period;
use RoundlyConsulting\Plausible\Enums\Property;

Metric::values();              // 'visitors', 'visits', 'pageviews', … — the raw wire keys
Metric::validationRule();      // 'in:visitors,visits,pageviews,…' for request validation
Period::toOptions();           // ['day' => 'Day', '7d' => 'Seven Days', …] for a <select>
Period::options();             // list of {value, label, name} DTOs for JS/Inertia
Period::fromName('SixMonths'); // Period::SixMonths

Period::SevenDays->readable();      // 'Seven Days'
Dimension::EventName->readable();   // 'Event Name'
Metric::ViewsPerVisit->readable();  // 'Views Per Visit'

Property::custom('plan');      // 'event:props:plan'
Dimension::custom('plan');     // 'event:props:plan'
```

## Validating user input

```php
use RoundlyConsulting\Plausible\Enums\Metric;
use RoundlyConsulting\Plausible\Enums\Period;

$validated = $request->validate([
    'metric' => ['required', Metric::validationRule()],
    'period' => ['required', Period::validationRule()],
]);

$result = Plausible::stats()
    ->query()
    ->metrics(Metric::from($validated['metric']))
    ->period(Period::from($validated['period']))
    ->aggregate();
```

## Labels vs wire values

value, values(), validationRule() and custom() always emit the raw API strings. Only the display label differs: Metric, Interval, GoalType and FilterOperator derive clean labels from the value (views\_per\_visit → Views Per Visit), while Period, Dimension and Property — whose values are abbreviations like 7d or ns:field tokens like event:name — derive them from the case name (SevenDays → Seven Days).

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/plausible-for-laravel.md)
