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/farmfun.komma.pro/app/Komma/Kms/Core/Attributes/QuantityDiscount.php
<?php

namespace App\Komma\Kms\Core\Attributes;

use App\Komma\Kms\Core\Attributes\Traits\ExplanationTrait;

/**
 * Class TextField
 */
class QuantityDiscount extends Attribute
{
    use ExplanationTrait;

    /** @var int The minimum allowed value */
    private $minCurrency;

    /** @var int The maximum allowed value */
    private $maxCurrency;

    /** @var float The legal number intervals */
    private $stepCurrency;

    /**
     * @var string
     */
    private $newPriceText;

    /**
     * @var string
     */
    private $whenAmountReachesText;

    /**
     * TextField constructor.
     * @param string $newPriceText
     * @param string $whenAmountReachesText
     */
    public function __construct(string $newPriceText, string $whenAmountReachesText)
    {
        parent::__construct();
        $this->stepCurrency = 0.01;
        $this->newPriceText = $newPriceText;
        $this->whenAmountReachesText = $whenAmountReachesText;
    }

    /**
     * Returns a view that visually represents this attribute
     *
     * @return \Illuminate\Contracts\View\View
     */
    public function render()
    {
        return \View::make('kms/attributes.quantity_discount', [
            'key'                   => (string) $this->getKey(),
            'minCurrency'           => $this->minCurrency,
            'maxCurrency'           => $this->maxCurrency,
            'stepCurrency'          => $this->stepCurrency,
            'styleClass'            => $this->getStyleClass(),
            'dataAttributes'        => $this->getDataAttributes(),
            'value'                 => $this->getValue(),
            'explanationText'       => $this->getExplanation(),
            'newPriceText'          => $this->newPriceText,
            'whenAmountReachesText' => $this->whenAmountReachesText,
        ]);
    }

    public function getDiscountPrice()
    {
        if ($this->value == '') {
            $this->value = '|';
        }

        return explode('|', $this->value)[1];
    }

    public function getQuantity()
    {
        if ($this->value == '') {
            $this->value = '|';
        }

        return explode('|', $this->value)[0];
    }
}