<?php

namespace App\Entities\Produccion;

use App\Entities\Usuarios\UserEntity;
use App\Models\OrdenTrabajo\OrdenTrabajoTarea;
use CodeIgniter\Entity\Entity;

class OrdenTrabajoTareaProgressDateEntity extends Entity
{
    protected $attributes = [
        "ot_tarea_id" => null,
        "action_at" => null,
        "action_user_id" => null,
        "estado" => null
    ];
    protected $datamap = [];
    protected $dates   = ['created_at', 'updated_at', 'deleted_at','action_at'];
    protected $casts   = [ ];

    /**
     * Orden de trabajo de la tarea
     *
     * @return OrdenTrabajoTareaEntity
     */
    public function orden_trabajo_tarea() : OrdenTrabajoTareaEntity 
    {
        $m = model(OrdenTrabajoTarea::class);
        return $m->find($this->attributes["ot_tarea_id"]);
    }
    public function user() : ?UserEntity
    {
        $user = null;
        if($this->attributes['action_user_id'])
        {
            $user = auth()->getProvider()->findById($this->attributes['action_user_id']);
        }
        return $user;
    }

}
