<?php

namespace App\Forms\Customer;

class ClientForm extends CustomerForm
{
  public function __construct()
  {
    parent::__construct();
  }
  public function getFormRule(string $action, string $field): string
  {
    switch ($field) {
      case "name":
        $rule = sprintf("required|trim|string%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
        break;
      case "site":
      case "role":
        $rule  = "required|trim|string";
        break;
      case "email":
        $rule = "permit_empty|trim|valid_email";
        break;
      case "phone":
      case "history":
        $rule = "permit_empty|trim|string";
        break;
      case "account_balance":
      case "coupon_balance":
      case "point_balance":
        $rule  = "permit_empty|numeric";
        break;
      default:
        $rule = parent::getFormRule($action, $field);
        break;
    }
    return $rule;
  }
}
