Commit 99bbf6bf627c904bfecdeee52c23a1b1586691ca
1 parent
0388bf4f0b
Exists in
master
Фикс
Showing 1 changed file with 3 additions and 3 deletions Inline Diff
app/Enums/WorkerStatuses.php
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace App\Enums; | 3 | namespace App\Enums; |
4 | 4 | ||
5 | use App\Enums\EnumTraits\EnumToArray; | 5 | use App\Enums\EnumTraits\EnumToArray; |
6 | 6 | ||
7 | enum WorkerStatuses: int | 7 | enum WorkerStatuses: int |
8 | { | 8 | { |
9 | use EnumToArray; | 9 | use EnumToArray; |
10 | 10 | ||
11 | case NotIndicated = 1; | 11 | case NotIndicated = 1; |
12 | case LookingForWork = 0; | 12 | case LookingForWork = 0; |
13 | case NotLookingForWork = 2; | 13 | case NotLookingForWork = 2; |
14 | case ConsideringOffers = 3; | 14 | case ConsideringOffers = 3; |
15 | 15 | ||
16 | public function label(): string | 16 | public function label(): string |
17 | { | 17 | { |
18 | return match($this) | 18 | return match($this) |
19 | { | 19 | { |
20 | self::LookingForWork => 'Ищу работу', | 20 | self::LookingForWork => 'Ищу работу', |
21 | self::NotIndicated => 'Не указано', | 21 | self::NotIndicated => 'Не указано', |
22 | self::NotLookingForWork => 'Не ищу работу', | 22 | self::NotLookingForWork => 'Не ищу работу', |
23 | self::ConsideringOffers => 'Рассматриваю предложения', | 23 | self::ConsideringOffers => 'Рассматриваю предложения', |
24 | }; | 24 | }; |
25 | } | 25 | } |
26 | 26 | ||
27 | public static function getWorkerStatuses(): array { | 27 | public static function getWorkerStatuses(): array { |
28 | $statuses_names = self::names(); | 28 | $statuses = self::cases(); |
29 | 29 | ||
30 | $result = []; | 30 | $result = []; |
31 | foreach ($statuses_names as $status_name){ | 31 | foreach ($statuses as $status) { |
32 | $result[self::{$status_name}->value] = self::{$status_name}->label(); | 32 | $result[$status->value] = $status->label(); |
33 | } | 33 | } |
34 | return $result; | 34 | return $result; |
35 | } | 35 | } |
36 | } | 36 | } |
37 | 37 |