75 lines
2.2 KiB
PHP
75 lines
2.2 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 [
|
|
"clientinfo_uid",
|
|
"type",
|
|
"model",
|
|
"manufactur_at",
|
|
"price",
|
|
"status",
|
|
"description",
|
|
];
|
|
}
|
|
public function getFilterFields(): array
|
|
{
|
|
return ["clientinfo_uid", "type", 'status'];
|
|
}
|
|
public function getBatchJobFields(): array
|
|
{
|
|
return ['type', 'status'];
|
|
}
|
|
public function getFormFieldOption(string $field, array $options = []): array
|
|
{
|
|
switch ($field) {
|
|
case 'cpu_partinfo_uid':
|
|
foreach ($this->getEntities(['type' => 'CPU']) as $entity) {
|
|
$options[$entity->getPK()] = $entity->getTitle();
|
|
}
|
|
break;
|
|
case 'ram_partinfo_uid':
|
|
foreach ($this->getEntities(['type' => 'RAM']) as $entity) {
|
|
$options[$entity->getPK()] = $entity->getTitle();
|
|
}
|
|
break;
|
|
case 'disk_partinfo_uid':
|
|
foreach ($this->getEntities(['type' => 'DISK']) as $entity) {
|
|
$options[$entity->getPK()] = $entity->getTitle();
|
|
}
|
|
break;
|
|
default:
|
|
$options = parent::getFormFieldOption($field, $options);
|
|
break;
|
|
}
|
|
// dd($options);
|
|
return $options;
|
|
}
|
|
}
|