autepos/discount-nke-laravel

Laravel wrapper for autepos/discount

Installs: 2

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/autepos/discount-nke-laravel

dev-main 2023-06-15 06:44 UTC

This package is auto-updated.

Last update: 2025-09-15 11:27:06 UTC


README

DiscountNkeLaravel is an implementation of autepos/discount for Laravel. It is designed to be similar to Stripe's Discount which is made up of a coupon and a promotion code. It not quite a wrapper around autepos/discount since it mainly implement the DiscountInstrument and interface and provides the necessary Eloquent models.

Requirements

  • PHP 8.0+
  • Laravel 9.x+

Installation

Install the package via composer:

composer require autepos/discount-nke-laravel

php artisan migrate

Usage

use Autepos\DiscountNkeLaravel\Contracts\DiscountProcessorFactory;
use Autepos\Discount\Contracts\DiscountableDevice;
use Autepos\DiscountNkeLaravel\Models\PromotionCode;

class Order implements DiscountableDevice
{
    //...
}


$discountableDevice = new Order();
$discountInstrument = new PromotionCode::find(1);

$processor = app(DiscountProcessorFactory::class);
$processor->addDiscountableDevice($discountableDevice)
          ->addDiscountInstrument($discountInstrument);
$discountLineList = $processor->calculate();

// Get the discount amount
$discountAmount = $discountLineList->amount();

// Persist the discount
$discountLineList->redeem();