Skip to content

easily create laravel coupon code with with lara-coupon ❤️ @code4mk

Notifications You must be signed in to change notification settings

code4mk/lara-coupon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lara-coupon

easily create laravel coupon code with with lara-coupon

installation

composer require code4mk/lara-coupon

setup

1) vendor publish

php artisan vendor:publish --provider="Code4mk\LaraCoupon\LaraCouponServiceProvider" --tag=config
php artisan vendor:publish --provider="Code4mk\LaraCoupon\LaraCouponServiceProvider" --tag=migrations

2) config

  • 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

method

create()

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

singleRedeem()

use KCoupon;
KCoupon::singleRedeem($code, $authUser)

singleUnredeem()

use KCoupon;
KCoupon::singleUnredeem($code, $authUser)

redeem()

use KCoupon;
KCoupon::redeem($code)

unredeam()

use KCoupon;
KCoupon::unredeam($code)

lists

use KCoupon;
KCoupon::lists();

activeLists

use KCoupon;
KCoupon::activeLists();

deactiveLists

use KCoupon;
KCoupon::deactiveLists();

general

use KCoupon;
KCoupon::general();

delete

use KCoupon;
KCoupon::delete($code);

check

use KCoupon;
KCoupon::check($code,$authUser);
  • check return
"status" => ,
"type" => ,
"is_product" => ,
"is_user" => ,
"is_quantity" => ,
"is_rsingle" => ,
"amount" =>