<?php

namespace App\Models\Customer;

use App\Entities\Customer\ServiceHistoryEntity;

class ServiceHistoryModel extends CustomerModel
{
    const TABLE = "serviceinfo_history";
    const PK = "uid";
    const TITLE = "title";
    protected $table            = self::TABLE;
    protected $primaryKey       = self::PK;
    protected $returnType       = ServiceHistoryEntity::class;
    protected $allowedFields = [
        "serviceinfo_uid",
        "title",
        "description",
        "status",
        "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 "serviceinfo_uid":
                $rule  = "required|numeric";
                break;
            case "title":
                $rule = "required|trim|string";
                break;
            default:
                $rule = parent::getFormFieldRule($action, $field);
                break;
        }
        return $rule;
    }
}
