/ app / Enums / InboxFileTypeEnum.php
InboxFileTypeEnum.php
 1  <?php
 2  
 3  namespace App\Enums;
 4  
 5  use Spatie\Enum\Enum;
 6  
 7  /**
 8   * @method static self certification_request()
 9   * @method static self ETR()
10   * @method static self partial_report()
11   * @method static self validacion_json()
12   * @method static self evaluation_request()
13   * @method static self OR()
14   *
15   * @method static self others()
16   */
17  class InboxFileTypeEnum extends Enum
18  {
19      public static function values(): array
20      {
21          return [
22              'certification_request' => 1,
23              'ETR' => 2,
24              'partial_report' => 3,
25              'validacion_json' => 4,
26              'evaluation_request' => 5,
27              'OR' => 6,
28              'others' => 7,
29          ];
30      }
31  
32      public static function id2name(int $id)
33      {
34          return match ($id) {
35              1 => 'InformeValidacionSolicitudCertificacion',
36              2 => 'ValidacionETR',
37              3 => 'ValidacionParcial',
38              4 => 'ValidacionJson',
39              5 => 'InformeValidacionSolicitudEvaluacion',
40              6 => 'OR',
41              7 => 'others',
42          };
43      }
44  
45      public static function id2lang(int $id)
46      {
47          return __('inbox-files.types.' . strval($id));
48      }
49  
50      public static function id2dirName(int $id)
51      {
52          return match ($id) {
53              1 => __('documents.folders.certification_requests'),
54              2 => __('documents.folders.ETRs'),
55              3 => __('documents.folders.partial_reports'),
56              4 => __('documents.folders.jsons'),
57              5 => __('documents.folders.evaluation_requests'),
58              6 => __('documents.folders.ORs'),
59              7 => __('documents.folders.others'),
60          };
61      }
62  
63  
64      public static function valueNameArray(): array
65      {
66          return collect(self::values())->map(function ($value) {
67              return ['id' => $value, 'name' => self::id2name($value)];
68          })->toArray();
69      }
70  
71      public static function valueLangArray(): array
72      {
73          return collect(self::values())->filter(function ($value) {
74              return $value !== self::validacion_json()->value;
75          })->map(function ($value) {
76              return ['id' => $value, 'name' => self::id2lang($value)];
77          })->toArray();
78      }
79  }