---
title: "Artisan commands — Credits for Laravel | Roundly"
description: "Apply a credit change in bulk with credits:modify, and inspect the resolved configuration with php artisan about."
url: https://roundly-consulting.com/open-source/docs/credits-for-laravel/commands
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)

# Artisan commands

credits:modify applies one credit change to every entity resolved by the credits.modifiable config, through Credits::for($entity) — so Credits::fake() records it. Register one or more resolver closures — each receives a $modify callback to call per entity:

```php
// config/credits.php
use App\Models\User;

'modifiable' => [
    function (Closure $modify): void {
        User::query()->each(fn (User $user) => $modify($user));
    },
],
```

Then run it:

```bash
php artisan credits:modify --amount=10 --description="monthly bonus"
# Modified credits on 42 entities.

php artisan credits:modify --amount=50 --description="monthly bonus" --bucket=promotional
php artisan credits:modify --amount=-5 --description="correction" --allow-overdraft
```

| Option | Default | Description |
| --- | --- | --- |
| `--amount` | — | Required: the credit amount to apply, a non-zero integer — negative to deduct. A missing, non-integer or 0 value prints an error and exits 1 before any resolver runs, so nothing is written. |
| `--description` | null | An optional human-readable description stored on each row. |
| `--bucket` | configured default | The named bucket to apply the change to. Omit to use default\_bucket. |
| `--allow-overdraft` | false | Permit deductions that drive the balance below minimum\_balance (which may be other than zero). |

- Each row the command writes carries meta \['info' => 'Credits modified by credits:modify command.'\].
- Resolved entities that are not Creditable models are skipped with a warning rather than failing the run.
- An entity whose deduction the overdraft guard refuses is skipped too: the run carries on with the rest and prints a Refused line for each.
- Once every entity has been visited, the command reports how many were refused and exits non-zero.
- Each change is its own transaction, so the entities that were charged stay charged — re-run only for the refused ones (for example with a resolver that selects them), not the whole set.
- With no resolvers registered, the command succeeds and changes nothing.

```bash
php artisan credits:modify --amount=-50 --description="monthly fee"
# Refused App\Models\User #2: Insufficient credits: tried to deduct 50 but only 20 are available.
# Modified credits on 41 entities.
# Refused 1 entity with insufficient credits.
echo $?   # 1 — the run finished, but not every entity was charged
```

## Inspecting the configuration

The package contributes a section to Laravel’s about command:

```bash
php artisan about --only=credits
```

| Row | Shows |
| --- | --- |
| Model | The resolved ledger model’s class name, or INVALID when credits.model is not Credit or a subclass. |
| Primary key type | credits.primary\_key\_type, or INVALID when it is not bigint, uuid or ulid — surfaced because a non-bigint id cannot be held by another package’s morphs() column on a strict engine. |
| Creditable key type | credits.key\_type, or INVALID when it is not bigint, uuid or ulid. |
| Overdraft | ALLOWED or BLOCKED — read from allow\_overdraft as a boolean, the same way the guard reads it; INVALID when the value is not a boolean. |
| Minimum balance | credits.minimum\_balance, or INVALID when the value is malformed — about keeps working. |
| Default bucket | credits.default\_bucket, or INVALID when the value is malformed. |
| Scale | credits.scale, or INVALID when the value is malformed. |
| Rounding | The display rounding mode in its config spelling, or INVALID when credits.rounding names no mode. |
| Modifiable resolvers | NONE or “N registered” — a count, never what they resolve; INVALID when credits.modifiable is malformed. |

## 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)
