dbms/app/Services/Equipment/PartService.php
2025-05-16 18:57:21 +09:00

65 lines
1.7 KiB
PHP

<?php
namespace App\Services\Equipment;
use App\Entities\Equipment\PartEntity;
use App\Models\Equipment\PartModel;
use CodeIgniter\HTTP\IncomingRequest;
use App\Services\Equipment\EquipmentService; // Ensure this path is correct and the class exists or create the class if missing
class PartService extends EquipmentService
{
protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null)
{
parent::__construct($request);
}
public function getClassName(): string
{
return parent::getClassName() . DIRECTORY_SEPARATOR . "Part";
}
public function getModelClass(): PartModel
{
return new PartModel();
}
public function getEntityClass(): PartEntity
{
return new PartEntity();
}
public function getFields(): array
{
return [
"type",
"model",
"manufactur_at",
"status",
"description",
];
}
public function getFilterFields(): array
{
return ["type", 'status'];
}
public function getBatchJobFields(): array
{
return ['type', 'status'];
}
public function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
case 'CPU':
case 'RAM':
case 'DISK':
foreach ($this->getEntities(['type' => $field]) as $entity) {
$options[$entity->getPK()] = $entity->getTitle();
}
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
// dd($options);
return $options;
}
}