/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Integration/Database/Enums.php
49 строк
888 B
Giorgio Balduzzi
[11.x] Accept non-backed enum in database queries (#50674)
21 мар 2024, 22:12
Не верифицирован
21 мар 2024, 22:12
08772cf
Код
Авторство
О чём код?
<?php namespace Illuminate\Tests\Integration\Database; use Illuminate\Contracts\Support\Arrayable; enum StringStatus: string { case draft = 'draft'; case pending = 'pending'; case done = 'done'; } enum IntegerStatus: int { case draft = 0; case pending = 1; case done = 2; } enum NonBackedStatus { case draft; case pending; case done; } enum ArrayableStatus: string implements Arrayable { case pending = 'pending'; case done = 'done'; public function description(): string { return match ($this) { self::pending => 'pending status description', self::done => 'done status description' }; } public function toArray() { return [ 'name' => $this->name, 'value' => $this->value, 'description' => $this->description(), ]; } }