<?php
namespace App\Entities\Tarifas\Maquinas;

use App\Entities\Tarifas\TarifaManipuladoEntity;
use App\Models\Tarifas\TarifaManipuladoModel;
use CodeIgniter\Entity\Entity;
use App\Entities\Configuracion\Maquina;
use App\Models\Configuracion\MaquinaModel;

class TarifaManipuladoMaquinaEntity extends Entity
{
    protected $attributes = [
        "id" => null,
        "tarifa_manipulado_id" => null,
        "maquina_id" => null,
        "maquina_tarea_id" => null,

    ];
    protected $casts = [
        "id" => "integer",
        "tarifa_manipulado_id" => "integer",
        "maquina_id" => "integer",
        "maquina_tarea_id" => "?integer",

    ];

    public function tarifa_manipulado(): TarifaManipuladoEntity
    {
        $m = model(TarifaManipuladoModel::class);
        return $m->find($this->attributes["tarifa_manipulado_id"]);
    }
    public function maquina(): ?Maquina
    {
        $m = model(MaquinaModel::class);
        return $m->find($this->attributes['maquina_id']);
    }
}
