| Total Complexity | 6 |
| Total Lines | 71 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class OrderStatus extends Model implements MorphToIssuerable |
||
| 11 | { |
||
| 12 | use HasFactory, |
||
| 13 | Concerns\OrderStatus\Attribute, |
||
| 14 | Concerns\OrderStatus\Relation; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * {@inheritDoc} |
||
| 18 | */ |
||
| 19 | protected $fillable = [ |
||
| 20 | 'status', |
||
| 21 | 'note', |
||
| 22 | ]; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * {@inheritDoc} |
||
| 26 | */ |
||
| 27 | protected $casts = [ |
||
| 28 | 'status' => EnumOrderStatus::class, |
||
| 29 | ]; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Determine whether the current status is not able to create order schedule. |
||
| 33 | * |
||
| 34 | * @return bool |
||
| 35 | */ |
||
| 36 | public function cantCreateSchedule(): bool |
||
| 37 | { |
||
| 38 | return EnumOrderStatus::draft()->equals($this->status); |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Determine whether the current status is able to create order schedule. |
||
| 43 | * |
||
| 44 | * @return bool |
||
| 45 | */ |
||
| 46 | public function canCreateSchedule(): bool |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Determine whether the order has been scheduled. |
||
| 53 | * |
||
| 54 | * @return bool |
||
| 55 | */ |
||
| 56 | public function hasBeenScheduled(): bool |
||
| 57 | { |
||
| 58 | return |
||
| 59 | EnumOrderStatus::scheduled()->equals($this->status) || |
||
| 60 | EnumOrderStatus::rescheduled()->equals($this->status); |
||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Determine whether the order has been finished. |
||
| 65 | * |
||
| 66 | * @return bool |
||
| 67 | */ |
||
| 68 | public function hasBeenFinished(): bool |
||
| 69 | { |
||
| 70 | return EnumOrderStatus::finished()->equals($this->status); |
||
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * Determine whether the order has been canceled. |
||
| 75 | * |
||
| 76 | * @return bool |
||
| 77 | */ |
||
| 78 | public function hasBeenCanceled(): bool |
||
| 81 | } |
||
| 82 | } |
||
| 83 |