79451345

Date: 2025-02-19 12:40:17
Score: 1
Natty:
Report link

Since the answers above did not work with Laravel 11, I decided to write my own

public static function getPossibleEnumValues(string $column): array
{
    $table = (new static)->getTable();
    $columnType = DB::selectOne("SHOW COLUMNS FROM {$table} WHERE Field = ?", [$column])->Type;

    if (preg_match('/^enum\((.*)\)$/', $columnType, $matches)) {
        return array_map(
            fn($value) => trim($value, "'"),
            str_getcsv($matches[1], ',', "'")
        );
    }

    return [];
}
Reasons:
  • Blacklisted phrase (1): did not work
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: user29711057