<?php

namespace App\Models\Equipment;

use App\Entities\Equipment\LineEntity;

class LineModel extends EquipmentModel
{
    const TABLE = "lineinfo";
    const PK = "uid";
    const TITLE = "title";
    protected $table            = self::TABLE;
    protected $primaryKey       = self::PK;
    protected $returnType       = LineEntity::class;
    protected $allowedFields = [
        "uid",
        "type",
        "title",
        "bandwith",
        "start_at",
        "end_at",
        "status",
        "updated_at"
    ];
    public function __construct()
    {
        parent::__construct();
    }
    public function getFormRule(string $action, string $field): string
    {
        if (is_array($field)) {
            throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
        }
        switch ($field) {
            case "bandwith":
            case "type":
                $rule = "required|trim|string";
                break;
            case "start_at":
            case "end_at":
                $rule = "permit_empty|valid_date";
                break;
            default:
                $rule = parent::getFormRule($action, $field);
                break;
        }
        return $rule;
    }
}
