<?php
namespace App\Models\Tarifas\Acabados;

use CodeIgniter\Database\BaseBuilder;

use CodeIgniter\Model;

class TarifasAcabadoServiciosAcabadoModel extends Model
{
    protected $table = 'tarifasAcabado_serviciosAcabado';
    protected $primaryKey = 'id';
    protected $useSoftDeletes = true;
    protected $allowedFields = ['tarifa_id', 'servicio_id', 'user_updated_id', 'created_at', 'updated_at', 'deleted_at'];
    protected $useTimestamps = true;

    protected $dateFormat = 'datetime';
    protected $createdField = 'created_at';
    protected $updatedField = 'updated_at';
    protected $deletedField = 'deleted_at';

    protected $returnType = 'App\Entities\Tarifas\Acabados\TarifasAcabadosServicioAcabadoEntity';

    public function getTarifasForServicio($servicioId)
    {
        $builder = $this->db
            ->table($this->table . " t1")
            ->select(
                "t1.tarifa_id",
            )
            ->where("t1.servicio_id", $servicioId)
            ->where("t1.deleted_at", null);
        $ids =  $builder->get()->getResultArray();
        
        return array_column($ids, 'tarifa_id');
    }
    
}


