- Deleted `data-table-actions.vue` component as it is no longer needed. - Removed `CuttingResultPriceItem` type and related properties from `cutting.ts`. - Updated routes in `web.php` to eliminate stock verification routes and permissions. - Removed `StockTest.php` file and its associated tests for stock verification and management. - Adjusted `CuttingTest.php` to reflect changes in cutting results handling and removed references to product variants.
72 lines
1.8 KiB
PHP
72 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Enums;
|
|
|
|
use App\Traits\ProvidesEnumOptions;
|
|
use InvalidArgumentException;
|
|
|
|
enum CuttingStatus: string
|
|
{
|
|
use ProvidesEnumOptions;
|
|
|
|
case IN_PROGRESS = 'in_progress';
|
|
case COMPLETED = 'completed';
|
|
|
|
public function label(): string
|
|
{
|
|
return match ($this) {
|
|
self::IN_PROGRESS => 'Proses',
|
|
self::COMPLETED => 'Selesai',
|
|
};
|
|
}
|
|
|
|
public function isEditable(): bool
|
|
{
|
|
return $this === self::IN_PROGRESS;
|
|
}
|
|
|
|
public function transitionStatusMessage(): string
|
|
{
|
|
return match ($this) {
|
|
self::COMPLETED => 'Proses cutting berhasil diselesaikan.',
|
|
default => 'Status proses cutting berhasil diperbarui.',
|
|
};
|
|
}
|
|
|
|
public function canTransitionTo(self $status): bool
|
|
{
|
|
return match ($this) {
|
|
self::IN_PROGRESS => $status === self::COMPLETED,
|
|
default => false,
|
|
};
|
|
}
|
|
|
|
public function transitionPermission(): Permission
|
|
{
|
|
return match ($this) {
|
|
self::COMPLETED => Permission::CUTTINGS_COMPLETE,
|
|
self::IN_PROGRESS => Permission::CUTTINGS_UPDATE,
|
|
default => throw new InvalidArgumentException('Status tidak mendukung transisi.'),
|
|
};
|
|
}
|
|
|
|
/**
|
|
* @return list<array{status: string, label: string, destructive: bool, permission: string, icon_only: bool}>
|
|
*/
|
|
public function availableActions(): array
|
|
{
|
|
return match ($this) {
|
|
self::IN_PROGRESS => [
|
|
[
|
|
'status' => self::COMPLETED->value,
|
|
'label' => 'Selesai',
|
|
'destructive' => false,
|
|
'permission' => Permission::CUTTINGS_COMPLETE->value,
|
|
'icon_only' => false,
|
|
],
|
|
],
|
|
default => [],
|
|
};
|
|
}
|
|
}
|