<?php

namespace App\Models\Customer;

use App\Entities\Customer\ServiceEntity;
use tidy;

class ServiceModel extends CustomerModel
{
    const TABLE = "serviceinfo";
    const PK = "uid";
    const TITLE = "title";
    protected $table = self::TABLE;
    // protected $useAutoIncrement = false;
    protected $primaryKey = self::PK;
    protected $returnType = ServiceEntity::class;
    protected array $nullableFields = [
        'serverinfo_uid',
        'end_at'
    ];
    protected $allowedFields = [
        "uid",
        "user_uid",
        "clientinfo_uid",
        "serverinfo_uid",
        "code",
        "title",
        "site",
        "location",
        "rack",
        "line",
        "billing_at",
        "sale",
        "amount",
        "start_at",
        "end_at",
        "history",
        "status",
    ];
    public function __construct()
    {
        parent::__construct();
    }
    //입력전 코드처리
    final public function create(array $formDatas): ServiceEntity
    {
        $formDatas['code'] = $formDatas['site'] . "_s" . uniqid();
        return parent::create($formDatas);
    }
}
