<?php

namespace App\Services\Equipment;

use App\Entities\Equipment\ServerEntity;
use App\Models\Equipment\ServerModel;
use CodeIgniter\HTTP\IncomingRequest;
use App\Services\Equipment\EquipmentService;

class ServerService extends EquipmentService
{
    protected ?IncomingRequest $request = null;
    public function __construct(?IncomingRequest $request = null)
    {
        parent::__construct($request);
        $this->addClassName('Server');
    }
    public function getModelClass(): ServerModel
    {
        return new ServerModel();
    }
    public function getEntityClass(): ServerEntity
    {
        return new ServerEntity();
    }
    public function getFields(): array
    {
        return [
            "code",
            "type",
            "model",
            "status",
            "description",
        ];
    }
    public function getFilterFields(): array
    {
        return ["type", 'model', 'status'];
    }
    public function getBatchJobFields(): array
    {
        return ["type", 'model', 'status'];
    }
    //서비스에서 사용중인 서버를 occupied로 변경
    public function setOccupied(ServerEntity $entity): ServerEntity
    {
        return $this->getModel()->modify($entity, ['status' => 'occupied']);
    }
}
