29 lines
822 B
PHP
29 lines
822 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace App\Actions\Discounts;
|
||
|
|
|
||
|
|
use App\Contracts\ActionInput;
|
||
|
|
use Domain\Enums\DiscountType;
|
||
|
|
use Domain\Models\ValueObjects\DatePeriod;
|
||
|
|
use Domain\Models\ValueObjects\DiscountValue;
|
||
|
|
use Webmozart\Assert\Assert;
|
||
|
|
|
||
|
|
final readonly class CreateDiscountInput implements ActionInput
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* @param array<string> $associatedProductsIds
|
||
|
|
*/
|
||
|
|
public function __construct(
|
||
|
|
public DiscountType $type,
|
||
|
|
public DiscountValue $value,
|
||
|
|
public bool $is_old_price_displayed,
|
||
|
|
public DatePeriod $period = new DatePeriod(),
|
||
|
|
public array $associatedProductsIds = [],
|
||
|
|
) {
|
||
|
|
Assert::same($this->type, $this->value->type, 'The discount value type must match the discount type.');
|
||
|
|
Assert::allString($this->associatedProductsIds);
|
||
|
|
}
|
||
|
|
}
|