51 lines
1.5 KiB
PHP
51 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Entities\OrderBillingEntity;
|
|
|
|
class OrderBillingModel extends BaseModel
|
|
{
|
|
protected $table = "tw_orderbilling";
|
|
protected $returnType = OrderBillingEntity::class;
|
|
public function __construct()
|
|
{
|
|
parent::__construct('Billing');
|
|
$this->allowedFields = [
|
|
...$this->allowedFields, "order_uid", "billing_uid"
|
|
];
|
|
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
|
|
}
|
|
final public function getTitleField(): string
|
|
{
|
|
return 'billing_uid';
|
|
}
|
|
public function getFieldRule(string $field, array $rules, string $action = ""): array
|
|
{
|
|
switch ($field) {
|
|
case "order_uid":
|
|
$rules[$field] = $this->getUUIDFieldRule('required');
|
|
break;
|
|
case 'billing_uid':
|
|
$rules[$field] = "required|numeric";
|
|
break;
|
|
default:
|
|
$rules = parent::getFieldRule($field, $rules, $action);
|
|
break;
|
|
}
|
|
return $rules;
|
|
}
|
|
public function getEntity($conditions): OrderBillingEntity
|
|
{
|
|
return parent::getEntity($conditions);
|
|
}
|
|
public function create(array $formDatas): OrderBillingEntity
|
|
{
|
|
return $this->create_process(new OrderBillingEntity(), $formDatas);
|
|
}
|
|
public function modify(OrderBillingEntity $entity, array $formDatas): OrderBillingEntity
|
|
{
|
|
return $this->modify_process($entity, $formDatas);
|
|
}
|
|
}
|