feat: add options method to enums for OrderChannel, OrderStatus, PaymentMethod, and PriceType to streamline data retrieval
This commit is contained in:
parent
00a9eb96d0
commit
e11df20ea6
@ -26,4 +26,12 @@ public function label(): string
|
||||
self::OTHER => 'Lainnya',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,4 +20,12 @@ public function label(): string
|
||||
self::CANCELLED => 'Gagal',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,4 +18,12 @@ public function label(): string
|
||||
self::QRIS => 'QRIS',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,4 +20,12 @@ public function label(): string
|
||||
self::RETAIL => 'Retail',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,10 +36,10 @@ public function create(): Response
|
||||
->whereNull('order_id')
|
||||
->latest()
|
||||
->get(),
|
||||
'orderStatus' => collect(OrderStatus::cases())->map(fn ($case) => ['value' => $case->value, 'label' => $case->label()]),
|
||||
'orderChannels' => collect(OrderChannel::cases())->map(fn ($case) => ['value' => $case->value, 'label' => $case->label()]),
|
||||
'paymentMethods' => collect(PaymentMethod::cases())->map(fn ($case) => ['value' => $case->value, 'label' => $case->label()]),
|
||||
'priceTypes' => collect(PriceType::cases())->map(fn ($case) => ['value' => $case->value, 'label' => $case->label()]),
|
||||
'orderStatus' => OrderStatus::options(),
|
||||
'orderChannels' => OrderChannel::options(),
|
||||
'paymentMethods' => PaymentMethod::options(),
|
||||
'priceTypes' => PriceType::options(),
|
||||
]);
|
||||
}
|
||||
|
||||
@ -108,10 +108,10 @@ public function edit(Order $order): Response
|
||||
return Inertia::render('admin/manage/order/edit', [
|
||||
'order' => $order,
|
||||
'products' => Product::with(['prices', 'categories'])->active()->get(),
|
||||
'orderStatus' => collect(OrderStatus::cases())->map(fn ($case) => ['value' => $case->value, 'label' => $case->label()]),
|
||||
'orderChannels' => collect(OrderChannel::cases())->map(fn ($case) => ['value' => $case->value, 'label' => $case->label()]),
|
||||
'paymentMethods' => collect(PaymentMethod::cases())->map(fn ($case) => ['value' => $case->value, 'label' => $case->label()]),
|
||||
'priceTypes' => collect(PriceType::cases())->map(fn ($case) => ['value' => $case->value, 'label' => $case->label()]),
|
||||
'orderStatus' => OrderStatus::options(),
|
||||
'orderChannels' => OrderChannel::options(),
|
||||
'paymentMethods' => PaymentMethod::options(),
|
||||
'priceTypes' => PriceType::options(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user