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/shop.komma.nl/database/seeds/CommonCoupons.php
<?php

namespace App\seeds;

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

/**
 * Class CommonCoupons
 *
 *  Needed for both testing and showcasing purposes
 *
 * @package App\seeds
 */
class CommonCoupons extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        return; //Fix
        //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
    }
}