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 Promocodes

Laravel Promocodes Laravel Package

zgabievi/laravel-promocodes

A Laravel package for creating and managing promo codes: generate unique codes, attach them to any Eloquent model, set fixed or percentage discounts, apply expiration dates and usage limits, then validate or redeem codes through a simple, expressive API.

View on GitHub
Deep Wiki
Context7

Coupons and promotional codes generator for Laravel.

Frequently asked questions about Laravel Promocodes
How do I install and set up zgabievi/laravel-promocodes in a Laravel app?
Install it with Composer using composer require zgabievi/laravel-promocodes. The service provider is registered through Laravel package discovery, so no manual provider entry is normally needed. Publish the package config and migrations, then run php artisan migrate to create the promocode tables. After that, set your user model association in the config file if you are not using the default App\Models\User.
Does laravel-promocodes support both percentage and fixed amount discounts?
Yes. When creating a promocode you can set the discount as either a fixed amount or a percentage, so the same package covers cart-style reductions and flat credits. The discount type and value are stored on the promocode record, which means your application reads them back at redemption time instead of hardcoding discount math in controllers. Keep your own rounding and currency rules in a service layer if you need locale-specific money handling.
How do I set an expiration date and a maximum number of usages on a promo code?
Expiration dates and usage limits are configured per promocode when you create or update it, so a code can be time-boxed, capped by total redemptions, or both. Redemption increments the usage counter, and once the cap or expiry is reached the code should no longer validate as available. The 9.1.0 release adds retrieval methods that cut down the custom query code needed to look up codes by state, so check the method signatures in the source for exactly which conditions each one covers.
Can I attach a promo code to any Eloquent model, not just users?
Yes, promocodes can be associated with any Eloquent model, so you can scope them to an order, a subscription, a tenant, or a team rather than only a user. That polymorphic-style association is what makes the package usable for multi-tenant and marketplace applications. The user model association itself is configurable, which matters if you use a custom user class.
How do I validate a promo code inside a Laravel form request instead of a controller?
The package ships a Laravel validation rule, added in 9.1.0, so you can put promo code availability checks directly in your FormRequest rules array next to required and string. That keeps availability logic at the request boundary instead of hand-rolling checks in service classes. If you already have custom promo code validation, pick one path rather than stacking both, otherwise users can see confusing duplicate error messages. Confirm the rule registers as expected on your installed Laravel major, since older versions may not handle string-based custom rules identically.
Does it work with a custom user model or a multi-guard setup?
The user model association is configurable, so a non-default class such as App\Models\User or a tenant-scoped user model can be wired in via config. Release 9.1.0 includes a fix for custom user model association, which is the highest-value change if you do not use the stock user model. Before and after upgrading, verify user-scoped promocode retrieval against your real model in staging, because that is the code path the fix touches. If you rely on multiple guards, test each guard separately rather than assuming the default guard applies.
Is upgrading from 9.0.x to 9.1.0 a breaking change?
No. It is a semver-minor release, so the expected contract is additive only: new promocode retrieval methods, a new validation rule, and a bug fix for custom user model association. No application code changes should be required, and no data migration is anticipated. Pin the exact version in composer.json, run your suite against production-like promocode fixtures in staging, and keep a rollback commit ready until post-deploy checks pass.
How do I redeem a promo code safely when many users redeem at once?
Redeem through the package API rather than writing to the promocode model directly, so the usage counter and availability checks stay consistent. Because usage limits are counter-based, test concurrent redemption in staging with realistic load before going live. If you expect bursts on a single code, wrap redemption in a database transaction or an atomic lock at your application layer. Also make sure your existing repository abstractions and the new retrieval methods do not create two parallel read paths to the same data.
Which Laravel and PHP versions does laravel-promocodes support?
Check the require block in the package composer.json against your runtime before installing, since constraints move between majors and this package is already on a v9 line. The validation rule assumes the framework validator available in your installed Laravel version, so an older major may need extra wiring. Run composer why-not zgabievi/laravel-promocodes in your project to see exactly which constraint blocks the install if resolution fails.
Is laravel-promocodes actively maintained, and what are the alternatives?
The project follows semantic versioning and reached a 9.x line, but no public security-response SLA or release cadence is published, so treat support posture as something to confirm before depending on it. For production, pin an exact version and keep a rollback commit ready rather than floating a caret range. Alternatives include building a small in-house promocode table with your own validation rule, or a broader e-commerce discount package if you need cart-level rules and stacking. For simple fixed or percentage codes with expiry and usage caps, this package covers the common case with very little glue code.
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.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
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