diff --git a/src/Enums/PriceStatus.php b/src/Enums/PriceStatus.php new file mode 100644 index 0000000..f9213bb --- /dev/null +++ b/src/Enums/PriceStatus.php @@ -0,0 +1,10 @@ + 'integer' + 'amount' => 'integer', + 'activated_at' => 'datetime', ]; public function __construct( @@ -80,17 +79,18 @@ public function toObject(): PriceObject return PriceObject::ofMinor($this->amount, $this->currency); } - public function getStatusAttribute() + public function getStatusAttribute(): PriceStatus { if($this->activated_at > now()) { - return 'programmed'; + return PriceStatus::SCHEDULED; } - $current = $this->priceable->price()->first(); - if($current->id == $this->id) { - return 'current'; + $current = $this->priceable->price()->current()->first(); + + if ($current->id == $this->id) { + return PriceStatus::CURRENT; } - return 'passed'; + return PriceStatus::EXPIRED; } }