Download the PHP package frittenkeez/laravel-vouchers without Composer
On this page you can find all versions of the php package frittenkeez/laravel-vouchers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download frittenkeez/laravel-vouchers
More information about frittenkeez/laravel-vouchers
Files in frittenkeez/laravel-vouchers
Package laravel-vouchers
Short Description Voucher system for Laravel 9+
License MIT
Informations about the package laravel-vouchers
Laravel Vouchers
Table of Contents
- Installation
- Upgrading
- Changelog
- Configuration
- Usage
- Generate Codes
- Create Vouchers
- Redeem Vouchers
- Options
- Events
- Traits
- Helpers
- Scopes
- Testing
- License
Installation
Install this package via Composer:
Upgrading
Please read the upgrade guide.
Changelog
Please read the release notes.
Configuration
Publish config using Artisan command:
Publish migrations using Artisan command:
Don't forget to run migrations:
Change basic configuration through config/vouchers.php
- it should be well documented, so no need to describe all options here.
Usage
This package comes with an ease-of-use facade Vouchers
with FQN FrittenKeeZ\Vouchers\Facades\Vouchers
.
Generate Codes
Generating codes without checking if they exist; defaults from config will be used if not specified.
Batch generation of codes is also possible; these will be checked against existing codes.
Create Vouchers
Generating one or more vouchers is just as simple.
Redeem Vouchers
Redeeming vouchers requires that one provides a redeemer entity.
Additional metadata for the redeemer can be provided.
Options
Besides defaults specified in config/vouchers.php
, one can override options when generating codes or creating vouchers.
Following methods apply to Vouchers::generate()
, Vouchers::batch()
and Vouchers::create()
calls.
Following methods only apply to Vouchers::create()
call.
All calls are chainable and dynamic options will be reset when calling Vouchers::create()
or Vouchers::reset()
.
Events
During events Voucher::$redeemer
will be set to the active redeemer (FrittenKeeZ\Vouchers\Models\Redeemer
).
By default vouchers will be marked as redeemed after one use, which is not always the desired outcome.
To allow a voucher to be redeemed multiple times, subscribe to the FrittenKeeZ\Vouchers\Models\Voucher::shouldMarkRedeemed()
event.
To prevent a voucher from being redeemed altogether, subscribe to the FrittenKeeZ\Vouchers\Models\Voucher::redeeming()
event.
To prevent a voucher from being redeemed by anyone but the related user.
To perform additional actions after a vouchers has been redeemed, subscribe to the FrittenKeeZ\Vouchers\Models\Voucher::redeemed()
event.
Traits
For convenience we provide some traits for fetching vouchers and redeemers for related entities, fx. users.
FrittenKeeZ\Vouchers\Concerns\HasRedeemers
FrittenKeeZ\Vouchers\Concerns\HasVouchers
You can also create vouchers owned by an entity using these convenience methods.
Helpers
Check whether a voucher code is redeemable without throwing any errors.
Check whether a voucher code exists, optionally also checking a provided list.
Additional helpers methods on Voucher model.
Scopes
For convenience we also provide Voucher scopes matching the helper methods.
Testing
Running tests can be done either through composer, or directly calling the PHPUnit binary.
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-vouchers with dependencies
illuminate/config Version ^9.0|^10.0|^11.0
illuminate/console Version ^9.0|^10.0|^11.0
illuminate/database Version ^9.0|^10.0|^11.0
illuminate/support Version ^9.0|^10.0|^11.0