An ecommerce voucher generator. It associates vouchers with one or more eloquent model and allows multiple models to own/redeem vouchers.
All documentation is available at the documentation site.
- ๐ Associate one voucher with one or more items
- โค Flexible Redeemer Models with polymorphic relationship to redeemers. Vouchers can be redeemed by any model. Useful for multi-auth or User/Guest architecture
- ๐ Use vouchers once or multiple times
- ๐ช Limit Access: can define model instances that are allowed or excluded from redeeming a Voucher
- Multiple limit scheme; exhaust redeems per instance, per user or per product
- Implements moirei/laravel-model-data
Example usage:
$product = Product::find(1);
$voucher = $product->createVoucher();
$user->redeemVoucher($voucher);
You can install the package via composer:
composer require moirei/laravel-vouchers
Next publish the migration with
php artisan vendor:publish --tag="vouchers-migrations"
Then run the migrations:
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="vouchers-config"
- The
allow_models
anddeny_models
attributes mentioned above are actually saved ascan_redeem
andcannot_redeem
internally. They are mutated on boot creating or updating. - If you manage your resources with Nova, Nova Multiselect can be used directly with the
can_redeem
andcannot_redeem
attributes. Example code here.
The MIT License (MIT). Please see License File for more information.