<?php

namespace App\Entities\Tarifas;

use CodeIgniter\Entity;

class TarifaEncuadernacionEntity extends \CodeIgniter\Entity\Entity
{
    protected $attributes = [
        "id" => null,
        "nombre" => null,
        "code" => null,
        "mostrar_en_presupuesto" => 1,
        "mostrar_en_presupuesto_cliente" => 0,
        "tipo_encuadernacion" => 0,
        "servicio_encuadernacion" => 0,
        "por_horas" => 0,
        "user_created_id" => 0,
        "user_updated_id" => 0,
        "is_deleted" => 0,
        "deleted_at" => null,
        "created_at" => null,
        "updated_at" => null,
    ];
    protected $casts = [
        "mostrar_en_presupuesto" => "int",
        "mostrar_en_presupuesto_cliente" => "bool",
        "code" => "string",
        "tipo_encuadernacion" => "int",
        "servicio_encuadernacion" => "int",
        "por_horas" => "int",
        "user_created_id" => "int",
        "user_updated_id" => "int",
        "is_deleted" => "int",
    ];

    public function getNameInitials(): string
    {
        $words = explode(" ",$this->attributes["nombre"]);
        $words_initial = array_map(fn($w) => substr(strtoupper($w),0,1),$words);
        return implode("",$words_initial);
    }

    

}
