<?php

namespace App\Models\Part;

use App\Entities\Part\SWITCHEntity;

class SWITCHModel extends PartModel
{
    const TABLE = "switchinfo";
    const PK = "uid";
    const TITLE = "code";
    protected $table            = self::TABLE;
    protected $primaryKey       = self::PK;
    // protected $useAutoIncrement = false;
    protected $returnType       = SWITCHEntity::class;
    protected $allowedFields = [
        "uid",
        "clientinfo_uid",
        "serviceinfo_uid",
        "serverinfo_uid",
        "code",
        "price",
        "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 "status":
                $rule  = "required|trim|string";
                break;
            default:
                $rule = parent::getFormRule($action, $field);
                break;
        }
        return $rule;
    }
}
