HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/werkenbij.komma.pro/app/Komma/Shop/seeds/SampleCouponSeeder.php
<?php

namespace App\Komma\Shop\seeds;

use App\Komma\Shop\Discounts\Actions\ModifyPriceAction;
use App\Komma\Shop\Discounts\Conditions\CouponDiscountCondition;
use App\Komma\Shop\Discounts\Discount;
use App\Komma\Shop\Discounts\DiscountTypes;
use Carbon\Carbon;
use Illuminate\Database\Seeder;

class SampleCouponSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        //Used in tests
        $discount = new Discount();
        $discount->type = DiscountTypes::Coupon;
        $discount->active = 1;
        $discount->valid_from = Carbon::now();
        $discount->valid_trough = Carbon::now()->addYear(50);
        $condition = new CouponDiscountCondition('Percentage5%');
        $action = new ModifyPriceAction(5,ModifyPriceAction::MethodPercentageWise); //Modify the price by lowering it with 5 percent
        $discount->setDiscountCondition($condition)->setDiscountAction($action);
        $discount->save(); //Save it to the database so that the discountService knows about it when it does it's job

        //Used in tests
        $discount = new Discount();
        $discount->type = DiscountTypes::Coupon;
        $discount->active = 1;
        $discount->valid_from = Carbon::now();
        $discount->valid_trough = Carbon::now()->addYear(50);
        $condition = new CouponDiscountCondition('Absolute5');
        $action = new ModifyPriceAction(500,ModifyPriceAction::MethodAbsolute); //Modify the price by lowering it with 500 cents
        $discount->setDiscountCondition($condition)->setDiscountAction($action);
        $discount->save(); //Save it to the database so that the discountService knows about it when it does it's job
    }
}