Promociones
This commit is contained in:
@ -17,6 +17,15 @@ class Promotion extends Common\Ideal\Model
|
||||
public Type $type;
|
||||
public State $state = State::ACTIVE;
|
||||
|
||||
protected array $projects;
|
||||
public function projects(): array
|
||||
{
|
||||
if (empty($this->projects)) {
|
||||
$this->projects = $this->runFactory('projects');
|
||||
}
|
||||
return $this->projects;
|
||||
}
|
||||
|
||||
protected array $contracts;
|
||||
public function contracts(): array
|
||||
{
|
||||
@ -35,6 +44,15 @@ class Promotion extends Common\Ideal\Model
|
||||
return $this->units;
|
||||
}
|
||||
|
||||
protected array $contractUnits;
|
||||
public function contractUnits(): array
|
||||
{
|
||||
if (empty($this->contractUnits)) {
|
||||
$this->contractUnits = $this->runFactory('contractUnits');
|
||||
}
|
||||
return $this->contractUnits;
|
||||
}
|
||||
|
||||
public function value(float $price): float
|
||||
{
|
||||
if ($this->type === Type::FIXED) {
|
||||
@ -53,6 +71,7 @@ class Promotion extends Common\Ideal\Model
|
||||
'valid_until' => $this->validUntil?->format('Y-m-d'),
|
||||
'type' => $this->type,
|
||||
'state' => $this->state,
|
||||
'projects' => $this->projects() ?? [],
|
||||
'contracts' => $this->contracts() ?? [],
|
||||
'units' => $this->units() ?? []
|
||||
];
|
||||
|
Reference in New Issue
Block a user