KOKINIO - MANAGER
Edit File: ComisionPago.php
<?php namespace App; use Illuminate\Database\Eloquent\Model; use DB; class ComisionPago extends Model { // protected $table = "comision_pago"; public $incrementing = false; public function getComisionPago($year = null, $month = null) { if($year == null){ $year = date('Y'); } if($month == null){ $month = date('m'); } $sql = "SELECT cp.id, SUM(cp.cantidad) cantidad, v.id, c.nombre FROM comision_pago cp JOIN venta v ON v.id = cp.venta_id AND Year(v.fecha_venta) = $year AND Month(v.fecha_venta) = $month AND v.status_id = 1 JOIN cliente c ON c.id = cp.cliente_id AND c.status_id = 1 WHERE cp.status_id = 1 "; $query = DB::select(DB::raw($sql)); if(count($query) != null){ return $query; } } }