<?php

namespace App\Enums;

enum FormType: string
{
    case TEXT = 'text';
    case TEXTAREA = 'textarea';
    case TINYMCE = 'tinymce';
    case SELECT = 'select';
    case RADIO = 'radio';
    case CHECKBOX = 'checkbox';
    case SWITCH = 'switch';
    case DATE = 'date';
    case DATETIME = 'datetime';
    case IMAGE = 'image';
    case FILE = 'file';
    case NUMBER = 'number';
    case COLOR = 'color';
    case TAGS = 'tags';

    public function label(): string
    {
        return match ($this) {
            self::TEXT => '单行文本',
            self::TEXTAREA => '多行文本',
            self::TINYMCE => '富文本编辑器',
            self::SELECT => '下拉选择',
            self::RADIO => '单选框',
            self::CHECKBOX => '复选框',
            self::SWITCH => '开关',
            self::DATE => '日期',
            self::DATETIME => '日期时间',
            self::IMAGE => '图片',
            self::FILE => '文件',
            self::NUMBER => '数字',
            self::COLOR => '颜色选择器',
            self::TAGS => '标签',
        };
    }

    public function needsOptions(): bool
    {
        return in_array($this, [self::SELECT, self::RADIO, self::CHECKBOX]);
    }
}
