---
title: "Configuration — Credits for Laravel | Roundly"
description: "Every config key and its default — model, key types, overdraft policy, default bucket, scale, rounding, currencies and bulk resolvers."
url: https://roundly-consulting.com/open-source/docs/credits-for-laravel/configuration
language: en
---

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

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

# Configuration

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

```php
<?php

declare(strict_types=1);

use RoundlyConsulting\Credits\Models\Credit;

return [

    'model' => Credit::class,

    'key_type' => env('CREDITS_KEY_TYPE', 'bigint'),

    'primary_key_type' => env('CREDITS_PRIMARY_KEY_TYPE', 'bigint'),

    'allow_overdraft' => env('CREDITS_ALLOW_OVERDRAFT', false),

    'minimum_balance' => 0,

    'default_bucket' => 'default',

    'scale' => 0,

    'rounding' => env('CREDITS_ROUNDING', 'half_away_from_zero'),

    'currencies' => [
        // 'store_credit' => 'EUR',
        // 'points' => 'PTS',
    ],

    'modifiable' => [
        //
    ],

];
```

## Every key

| Key | Default | Env | Purpose |
| --- | --- | --- | --- |
| `model` | Credit::class | — | The Eloquent model for ledger rows. Point it at your own subclass of Credit to customise behaviour or the table; anything that is not Credit or a subclass throws InvalidConfigurationException. |
| `key_type` | bigint | CREDITS\_KEY\_TYPE | Key type of your creditable models (the creditable\_id morph column): bigint, uuid or ulid; anything else throws InvalidConfigurationException. Fixed when the migration runs. |
| `primary_key_type` | bigint | CREDITS\_PRIMARY\_KEY\_TYPE | The credits table’s own id: bigint, uuid or ulid; anything else throws InvalidConfigurationException. Fixed when the migration runs. |
| `allow_overdraft` | false | CREDITS\_ALLOW\_OVERDRAFT | When false, a deduction that would take a bucket below minimum\_balance throws InsufficientCreditsException. True permits deductions below minimum\_balance globally. The env value is read as a boolean: 1, true, on and yes enable it; 0, false, off and no leave it off; anything else throws InvalidConfigurationException naming the key. |
| `minimum_balance` | 0 | — | The floor enforced when overdraft is disallowed. An int or a canonical integer string ('50', '-100'); blank ('') is not set, so 0 applies; anything else ('fifty', '50.5') throws InvalidConfigurationException instead of becoming 0. |
| `default_bucket` | 'default' | — | The bucket for reads and writes that omit one. A bucket-less balance returns this bucket only — it never sums across buckets. A blank value is not set, so 'default' applies; a non-string value throws InvalidConfigurationException. |
| `scale` | 0 | — | Decimal places the stored integers encode. Read only by the display helpers; a currency-denominated bucket ignores it. An integer from 0 to 36 (or its canonical string); anything else throws InvalidConfigurationException. |
| `rounding` | half\_away\_from\_zero | CREDITS\_ROUNDING | Default display rounding mode — a \\RoundingMode case in snake\_case. Not set (absent, null or a blank CREDITS\_ROUNDING=) means half\_away\_from\_zero; an unknown value throws InvalidMoneyConfiguration on first use. |
| `currencies` | \[\] | — | Bucket name → money currency code (ISO or custom). Resolved lazily, on first use. |
| `modifiable` | \[\] | — | Resolver closures for credits:modify. Each receives a $modify callback to apply the change to a Creditable entity. A non-array value or a non-callable entry throws InvalidConfigurationException. |

## Environment

The deployment-sensitive keys are env-backed:

```bash
CREDITS_KEY_TYPE=bigint
CREDITS_PRIMARY_KEY_TYPE=bigint
CREDITS_ALLOW_OVERDRAFT=false
CREDITS_ROUNDING=half_away_from_zero
```

## Things to decide early

- key\_type and primary\_key\_type are read when the migration runs — choose them before you publish and migrate. Changing either afterwards is a data migration, not a config change.
- An unrecognized key type throws InvalidConfigurationException naming the key — it never falls back to bigint.
- Every other setting is read strictly too: a key that is not set — absent, null or blank (a host’s KEY=) — takes its default, and a present value of the wrong shape — fifty for the floor, an array for the bucket, a string where the resolver list belongs — throws InvalidConfigurationException naming the key. A typo is never cast to 0 or swapped for the default.
- credits.currencies is resolved lazily on every use, never at boot, so a custom currency registered in your own provider’s boot() is accepted.
- credits.rounding must name a \\RoundingMode case in snake\_case; the legacy PHP\_ROUND\_\* integers are refused.
- CREDITS\_ALLOW\_OVERDRAFT is read as a boolean — off, no and false really leave overdraft off, and php artisan about reports exactly what the guard enforces.

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