PHP code example of zaratedev / laravel-discounts

1. Go to this page and download the library: Download zaratedev/laravel-discounts 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/ */

    

zaratedev / laravel-discounts example snippets





use Zaratedev\Discounts\Traits\Discountable;

class Item extends Model
{
    use Discountable;
}

...

$item = Item::find(1);
$item->createDiscount(100);


$subscription = Subscription::find(1);

$discounts = Discounts::create($subscription, 3, 100);

$subscription = Subscription::find(1);

// Returns an array of Discounts
$discounts = $subscription->createDiscounts(3, 100);

// Return a Discount model

$discount = $subscription->createDiscount(100);

$subscription = Subscription::find(1);

$subscription->createDiscounts(3, 100, today()->addMonths(4))

$discount->redeem();
bash
php artisan vendor:publish --provider="Zaratedev\Discounts\DiscountsServiceProvider" --tag="migrations"
bash
php artisan migrate