Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Vouchers

Laravel Vouchers Laravel Package

frittenkeez/laravel-vouchers

Laravel Vouchers offers an Eloquent-backed way to create, issue, and redeem voucher codes. Track usage, associate vouchers with models, and manage redemption state through a simple API for discounts, invites, credits, or other redeemable rewards.

View on GitHub
Deep Wiki
Context7

Voucher system for Laravel 12+

Frequently asked questions about Laravel Vouchers
How do I install and configure laravel-vouchers in a Laravel application?
Install it with composer require frittenkeez/laravel-vouchers, then publish the config and migrations with php artisan vendor:publish and run php artisan migrate. The package ships Eloquent models, a Vouchers facade, and publishable config, so Laravel package discovery handles the wiring. Confirm your application is on Laravel 12.4 or newer before starting, since that is the package's minimum.
Which Laravel versions does frittenkeez/laravel-vouchers support?
Version 0.9.0 requires Laravel 12.4 or later, the release where the #[Scope] attribute became available. Laravel 11 support was dropped in that release, so teams still on Laravel 11 must upgrade the framework before adopting the counter features, batch optimization, or bug fixes. Pin the package version in composer.json if you need to stay on an older framework for now.
How do I create and redeem a voucher code with laravel-vouchers?
Use the Vouchers facade to create a code, for example Vouchers::withCode('SUMMER'), then attach an owner or entity and call redeem() on the voucher. You can also pass a Voucher instance directly into redeem(), redeemable(), or the unredeem methods to skip a redundant lookup on the hottest path. Redemption counts and state are stored on the voucher, so you can check remaining uses or unredeem a voucher later.
Why is my generated voucher code being suffixed with a counter, like SUMMER-1?
In 0.9.0, calling Vouchers::withCode() with an amount greater than one now appends a counter to each generated code instead of throwing InfiniteLoopException. A request for SUMMER can therefore produce SUMMER-1, which breaks any downstream regex, fixed-length assumption, printed collateral, or third-party system expecting the exact literal. Audit every call site that generates multiple codes and make sure validators and consumers tolerate the suffix, because this happens without logging an error.
How do I associate a voucher with a user or another Eloquent model?
Vouchers support polymorphic attribution through withOwner() for the model receiving the voucher and withEntity() for the thing being redeemed against. That lets you attach vouchers to users, teams, orders, or any other Eloquent model without extra schema work. Both relations run through the shipped Voucher, Redeemer, and VoucherEntity models, which you can extend and swap in the package config.
Why does voucher metadata return an ArrayObject instead of an array?
As of 0.9.0, Voucher::$metadata and Redeemer::$metadata return an ArrayObject rather than a plain array. Code that passes metadata to array_* functions, compares it loosely, serializes it into queued jobs, or json_encodes it into API responses may change output or throw. New installs get a json column for metadata while existing installs keep the original text column, so JSON query features such as whereJsonContains may not work until you migrate that column.
What are alternatives to laravel-vouchers for coupon and voucher features in Laravel?
If you only need a small, fixed set of promo rules, a hand-rolled Eloquent model with a code column and a redemption table is often enough. If your discounts live in Stripe subscriptions, Laravel Cashier's coupon and promotion code support avoids duplicating that logic locally. laravel-vouchers is worth it when you want polymorphic owner and entity attribution, usage tracking, and a facade-driven API out of the box.
Can laravel-vouchers handle bulk issuance or high-volume voucher generation?
Bulk issuance is much cheaper in 0.9.0 because candidate codes are validated in chunks of 500, so generating 100 vouchers takes one query instead of 100. Uniqueness is still coordinated through the database, however, so the package is not a fit for distributed code generation across regions or extremely high write throughput. For very large campaigns, generate in batches and consider a dedicated code-generation strategy outside the default scope.
How do I test voucher redemption in my Laravel test suite?
Use RefreshDatabase or DatabaseTransactions in your tests and interact with the package through the Vouchers facade and the shipped models. Because the models are extendable and configurable, you can bind your own subclasses in tests to add factories or fake behaviour. Assert on redemption counts and voucher state rather than on generated code strings, since withCode() may append a counter suffix.
Is laravel-vouchers production ready, and what should I watch for when upgrading?
The package is pre-1.0 and maintained by a single author, and the 0.8.1 to 0.9.0 delta alone carried eight breaking changes, so expect more churn before 1.0. Pin an exact version, read the release notes for every bump, and budget for the Laravel 12.4 upgrade if you have not made it yet. When upgrading, treat the Voucher::code() to withCode() scope rename, scopes becoming protected, and the first-parameter rename from $code to $voucher as call sites that need checking.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo
bernskioldmedia/laravel-harvest
bernskiold/laravel-data-scrubber
bernskiold/laravel-currency-converter
bernskiold/laravel-campaign-monitor
bernskioldmedia/laravel-autotranslate
siberfx/telegram-bot
roy-sandip/laravel-view-extended
gregsphotography/site-builder-core
roy-sandip/laravel-view
anodyne/blade-fluentui-icons
webx-ui/module-catalog-collections