---
title: "Configuration — Coupons for Laravel | Roundly"
description: "Every config key, its default and env variable — coupon model, redeemer key type, default currency, tracking, code format and route key."
url: https://roundly-consulting.com/open-source/docs/coupons-for-laravel/configuration
language: en
---

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

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

# Configuration

The package ships sensible defaults and works with zero configuration. The published config/coupons.php in full:

```php
use RoundlyConsulting\Coupons\Models\Coupon;

return [
    'model' => Coupon::class,

    // Key type of the polymorphic redeemer column: "bigint", "uuid" or "ulid".
    'key_type' => env('COUPONS_KEY_TYPE', 'bigint'),

    'default_currency' => env('COUPONS_CURRENCY', 'USD'),

    'redeemer' => [
        'track' => env('COUPONS_TRACK_REDEEMERS', true),
    ],

    'code' => [
        'length' => env('COUPONS_CODE_LENGTH', 6),
        'charset' => env('COUPONS_CODE_CHARSET', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'),
    ],

    'route_key' => env('COUPONS_ROUTE_KEY', 'code'),
];
```

## Every key

| Key | Type | Default | Env | Purpose |
| --- | --- | --- | --- | --- |
| `model` | class-string | Coupon::class | — | The coupon model. Point it at a subclass of the package Coupon; anything else throws InvalidConfigurationException naming the key. The manager, actions, rule, both commands and Coupons::fake() use it. |
| `key_type` | string | bigint | COUPONS\_KEY\_TYPE | Key type of the polymorphic redeemer column on coupon\_redemptions: bigint, uuid or ulid. Read by the migration — set it before migrating. Anything else throws InvalidConfigurationException naming the key. |
| `default_currency` | string | USD | COUPONS\_CURRENCY | ISO 4217 code the shipped CouponFactory locks fixed and capped coupons to when a state names none; also shown by about. Redemption never assumes a currency — it always takes the cart total’s. A blank value (COUPONS\_CURRENCY=) is not set, so USD applies; a non-string value throws InvalidCouponConfiguration naming the key. |
| `redeemer.track` | bool | true | COUPONS\_TRACK\_REDEEMERS | Write a coupon\_redemptions row for every redemption that has a redeemer — powers per-redeemer caps, usageBy() and hasRedeemed(). When off, no rows are written and the per-redeemer cap isn’t enforced. Env-style values work: 1/true/on/yes and 0/false/off/no; a blank value is not set, so tracking stays on; anything else throws InvalidConfigurationException naming the key. |
| `code.length` | int | 6 | COUPONS\_CODE\_LENGTH | Length of auto-generated codes, 4–64. An integer string such as “8” works; a blank value is not set, so 6 applies; “eight” or “8.5” throws. |
| `code.charset` | string | A–Z 0–9 | COUPONS\_CODE\_CHARSET | Alphabet for generated codes: at least 2 distinct symbols (case-insensitively), no whitespace or control characters. It’s upper-cased like every code; multibyte symbols are fine. A blank value is not set, so A–Z 0–9 applies. |
| `route_key` | string | code | COUPONS\_ROUTE\_KEY | Column used for route-model binding of {coupon}. Set it to id to bind by primary key. A blank value is not set, so code applies; a non-string value throws InvalidCouponConfiguration naming the key rather than binding by code. |

## Environment

Every key except model is env-backed, so you rarely need to publish the config at all:

```bash
COUPONS_KEY_TYPE=bigint
COUPONS_CURRENCY=EUR
COUPONS_TRACK_REDEEMERS=true
COUPONS_CODE_LENGTH=8
COUPONS_CODE_CHARSET=ABCDEFGHJKLMNPQRSTUVWXYZ23456789
COUPONS_ROUTE_KEY=code
```

COUPONS\_TRACK\_REDEEMERS takes env-style values: 1, true, on or yes keep tracking on; 0, false, off or no switch it off; a blank value (COUPONS\_TRACK\_REDEEMERS=) is not set, so tracking stays on. Anything else throws InvalidConfigurationException naming the key.

A key you remove, set to null or leave blank (COUPONS\_CURRENCY=) is not set and takes its default; a key you set to a value of the wrong shape throws instead of falling back, and php artisan about shows a broken route\_key, default\_currency or code.\* value as INVALID, with the reason. An unusable code.length or code.charset throws InvalidCouponConfiguration the moment a code is generated — see Generated codes; a non-string route\_key or default\_currency throws it when read. key\_type is read only when the migration runs.

## 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/coupons-for-laravel.md)
