<?php

namespace App\Modelos;

use Core\Database;

class NotadeCreditoDetalles extends Database
{
    protected $table    = 'app_nota_de_credito_detalles';
    protected $id       = 'credet_id';

    public function obtenerDetalles()
    {
        return $this->consultar('SELECT * 
        FROM app_notas_de_credito')->all();
    }

    public function obtenerPagosCreditos(int $id_credito)
    {
        return $this->consultar("SELECT * FROM $this->table WHERE credet_creid = $id_credito")->all();
    }

    public function obtenerTotalPagosCreditos(int $id_credito)
    {
        return $this->consultar("SELECT SUM(credet_monto) total FROM $this->table WHERE credet_creid = $id_credito")->row();
    }
}
