30 lines
882 B
PHP
30 lines
882 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Actions\Discounts;
|
|
|
|
use App\Contracts\ActionInput;
|
|
use App\Models\Discount;
|
|
use Domain\Enums\DiscountType;
|
|
use Domain\Models\ValueObjects\DatePeriod;
|
|
use Domain\Models\ValueObjects\DiscountValue;
|
|
use Webmozart\Assert\Assert;
|
|
|
|
final readonly class UpdateDiscountInput implements ActionInput
|
|
{
|
|
/**
|
|
* @param array<string> $associatedProductsIds
|
|
*/
|
|
public function __construct(
|
|
public Discount $discount,
|
|
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);
|
|
}
|
|
}
|