1. Go to this page and download the library: Download aberkanidev/laravel-coupons 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/ */
return [
/*
* Database table name that will be used in migration
*/
'table' => 'coupons',
/*
* Database table name for voucherable models
*/
'voucherable_table' => 'voucherables',
/*
* List of characters that will be used for coupon code generation.
*/
'characters' => '23456789ABCDEFGHJKLMNPQRSTUVWXYZ',
/*
* Coupon code prefix.
*
* Example: foo
* Generated Code: foo-AGXF-1NH8
*/
'prefix' => null,
/*
* Coupon code suffix.
*
* Example: foo
* Generated Code: AGXF-1NH8-foo
*/
'suffix' => null,
/*
* Code mask.
* All asterisks will be removed by random characters.
*/
'mask' => '****-****',
/*
* Separator to be used between prefix, code and suffix.
*/
'separator' => '-',
];
$item = Item::find(1);
// Create 10 coupons using the Facade
// Returns an array of Coupons
$coupons = Coupons::create($item, 5);
// Create 3 coupons using the Eloquent model
// Returns an array of Coupons
$coupons = $item->createCoupons(2);
// Create a single coupon
$coupons = $item->createCoupon();