eldegweydev/coupon

There is no license information available for the latest version (dev-master) of this package.

Coupon CRUD Package For Laravel

dev-master 2023-04-28 16:26 UTC

This package is auto-updated.

Last update: 2024-04-28 18:43:55 UTC


README

This package help you to generate the CRUD for coupon codes and easily apply the coupons and verify it. It offer different types of discounts, Fixed and Percentage discounts.

Installation

First, install Package into your project using the Composer package manager:

composer require eldegweydev/coupon

Run migrations

Finally, run database migration

php artisan migrate

Routes List

Can access the coupons routes from this table

Method Action URI
GET index /coupons
GET show /coupons/{coupon}
GET create coupons/create
POST store /coupons
GET edit /coupons/{coupon}/edit
PUT update /coupons/{coupon}
DELETE destroy /coupons/{coupon}

Usage

To verify coupon code and apply the discount , you can use the provided Trait Coupon, it has two functions one for check the coupon is active and second to apply the coupon discount

use Eldegweydev\Coupon\Http\Traits\CouponTrait

use CouponTrait;

$this->checkCouponIsActive($code,$select = ['*']);

$this->calculateCouponDiscount($code,$total_price);