Nuevo models
This commit is contained in:
39
src/nuevo/Venta/Pie.php
Normal file
39
src/nuevo/Venta/Pie.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property int cuotas
|
||||
* @property double valor
|
||||
* @property Pie asociado_id
|
||||
* @property double uf
|
||||
*
|
||||
*/
|
||||
class Pie extends NewModel
|
||||
{
|
||||
protected static $_table = 'pies';
|
||||
|
||||
public function asociado()
|
||||
{
|
||||
$pie = $this->belongsTo(Pie::class, 'asociado_id');
|
||||
if ($pie) {
|
||||
return $pie->findOne();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public function Cuotas()
|
||||
{
|
||||
return $this->hasMany(Cuota::class, 'pie_id')->findMany();
|
||||
}
|
||||
public function CuotasPagadas()
|
||||
{
|
||||
return $this->hasMany(Cuota::class, 'pie_id')->filter(function($cuota) {
|
||||
$estado = $cuota->pago->ultimoEstado()->estado->descripcion;
|
||||
return ($estado == 'depositado' or $estado == 'abonado');
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user