bu4ak / promocode
1.0.0
2018-03-03 10:38 UTC
This package is auto-updated.
Last update: 2024-09-21 04:57:22 UTC
README
A small model that generates a discount code
Installation:
composer require bu4ak/promocode
php artisan migrate
Usage example:
- Generate:
$promo = \Bu4ak\Promocode\Models\Promocode::generate(10, 5); route('promo', ['hash' => $promo->hash]); // invitation link: // http://localhost/promo/356ce01e0258f76ad83a7734b28142f144264689e8983b38f0f5948bae6dda51
- Url handling:
Route::get('/promo/{hash}', function ($hash) { $promo = \Bu4ak\Promocode\Models\Promocode::whereHash($hash)->firstOrFail(); //or return view return ['your code' => $promo->code, 'discount' => $promo->discount]; })->name('promo');