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',
|
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',
|
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',
|
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',
|
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')
|
->whereNull('order_id')
|
||||||
->latest()
|
->latest()
|
||||||
->get(),
|
->get(),
|
||||||
'orderStatus' => collect(OrderStatus::cases())->map(fn ($case) => ['value' => $case->value, 'label' => $case->label()]),
|
'orderStatus' => OrderStatus::options(),
|
||||||
'orderChannels' => collect(OrderChannel::cases())->map(fn ($case) => ['value' => $case->value, 'label' => $case->label()]),
|
'orderChannels' => OrderChannel::options(),
|
||||||
'paymentMethods' => collect(PaymentMethod::cases())->map(fn ($case) => ['value' => $case->value, 'label' => $case->label()]),
|
'paymentMethods' => PaymentMethod::options(),
|
||||||
'priceTypes' => collect(PriceType::cases())->map(fn ($case) => ['value' => $case->value, 'label' => $case->label()]),
|
'priceTypes' => PriceType::options(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,10 +108,10 @@ public function edit(Order $order): Response
|
|||||||
return Inertia::render('admin/manage/order/edit', [
|
return Inertia::render('admin/manage/order/edit', [
|
||||||
'order' => $order,
|
'order' => $order,
|
||||||
'products' => Product::with(['prices', 'categories'])->active()->get(),
|
'products' => Product::with(['prices', 'categories'])->active()->get(),
|
||||||
'orderStatus' => collect(OrderStatus::cases())->map(fn ($case) => ['value' => $case->value, 'label' => $case->label()]),
|
'orderStatus' => OrderStatus::options(),
|
||||||
'orderChannels' => collect(OrderChannel::cases())->map(fn ($case) => ['value' => $case->value, 'label' => $case->label()]),
|
'orderChannels' => OrderChannel::options(),
|
||||||
'paymentMethods' => collect(PaymentMethod::cases())->map(fn ($case) => ['value' => $case->value, 'label' => $case->label()]),
|
'paymentMethods' => PaymentMethod::options(),
|
||||||
'priceTypes' => collect(PriceType::cases())->map(fn ($case) => ['value' => $case->value, 'label' => $case->label()]),
|
'priceTypes' => PriceType::options(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user