PHP code example of bu4ak / promocode
1. Go to this page and download the library: Download bu4ak/promocode library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bu4ak / promocode example snippets
$promo = \Bu4ak\Promocode\Models\Promocode::generate(10, 5);
route('promo', ['hash' => $promo->hash]);
// invitation link:
// http://localhost/promo/356ce01e0258f76ad83a7734b28142f144264689e8983b38f0f5948bae6dda51
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');