| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace App\Enums;
- use RuntimeException;
- class DocumentTypes extends AbstractEnum {
- public const SALES_ORDER = 0;
- public const DELIVERY_NOTE = 1;
- public const GOODS_IN = 2;
- public const ADVANCE_REPLACEMENT_UNIT = 3;
- public const CREDIT_NOTE = 4;
- public static function options(): array {
- return [
- self::SALES_ORDER => __("Sales Order"),
- self::DELIVERY_NOTE => __("Delivery Note"),
- self::GOODS_IN => __("Goods-In"),
- self::ADVANCE_REPLACEMENT_UNIT => __("ARU"),
- self::CREDIT_NOTE => __("Credit Note"),
- ];
- }
- public static function fromRouteName(string $name): string {
- $map = [
- "sales-orders" => self::SALES_ORDER,
- "delivery-notes" => self::DELIVERY_NOTE,
- "goods-in" => self::GOODS_IN,
- "arus" => self::ADVANCE_REPLACEMENT_UNIT,
- ];
- if(!isset($map[$name])) {
- throw new RuntimeException(__("Invalid document type."));
- }
- return $map[$name];
- }
- }
|