easily create laravel coupon code with with lara-coupon
composer require code4mk/lara-coupon
php artisan vendor:publish --provider="Code4mk\LaraCoupon\LaraCouponServiceProvider" --tag=config
php artisan vendor:publish --provider="Code4mk\LaraCoupon\LaraCouponServiceProvider" --tag=migrations
config/laraCoupon.php
- setup
expired time
,prefix
,code length
expire time
must be follow P7Y5M4DT4H3M2S
"expired" => "PT12M",
"isCodePrefix" => true,
"codePrefix" => "PMM-",
"codeLenght" => 10
php artisan config:clear
use KCoupon;
KCoupon::create($authUser)
-
create method has more request data
-
code,quantity,type,amount,product_id,user_id,rsingle,description
-
if you want auto code that time don't use
code
in request query -
if coupon code will need quantity that time use request query
quantity=integer
as?quantity=20
-
type is fix or per (percent)
?type=fix
,?type=per
-
amount
?amount=120
,?amount=10
-
specific product's coupon
?product_id=12
-
specific user's coupon
?user_id=2
-
redeem one user only one time
?rsingle=true
-
all products coupon for all user
- without query
product_id,user_id
- without query
use KCoupon;
KCoupon::singleRedeem($code, $authUser)
use KCoupon;
KCoupon::singleUnredeem($code, $authUser)
use KCoupon;
KCoupon::redeem($code)
use KCoupon;
KCoupon::unredeam($code)
use KCoupon;
KCoupon::lists();
use KCoupon;
KCoupon::activeLists();
use KCoupon;
KCoupon::deactiveLists();
use KCoupon;
KCoupon::general();
use KCoupon;
KCoupon::delete($code);
use KCoupon;
KCoupon::check($code,$authUser);
- check return
"status" => ,
"type" => ,
"is_product" => ,
"is_user" => ,
"is_quantity" => ,
"is_rsingle" => ,
"amount" =>