<?php

namespace App\Models\Equipment\Part;

use App\Entities\Equipment\Part\LineEntity;

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