40 lines
1006 B
PHP
40 lines
1006 B
PHP
<?php
|
|
namespace App\Exports;
|
|
|
|
use App\Invoice;
|
|
use App\Models\Venta;
|
|
use Illuminate\Contracts\View\View;
|
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
|
use Maatwebsite\Excel\Concerns\FromView;
|
|
|
|
class VentasExport implements FromView{
|
|
|
|
public $fecha_inicio, $fecha_final;
|
|
|
|
public function __construct($fecha_inicio, $fecha_final)
|
|
{
|
|
$this->fecha_inicio = $fecha_inicio;
|
|
$this->fecha_final = $fecha_final;
|
|
}
|
|
|
|
public function collection()
|
|
{
|
|
return Venta::select(
|
|
'codigo',
|
|
'pago_efectivo',
|
|
'pago_tarjeta_debito',
|
|
'pago_tarjeta_credito',
|
|
'pago_vales',
|
|
'precio_venta',
|
|
'estado_venta_id as tipo_venta',
|
|
'user_id as usuario',
|
|
)->get();
|
|
}
|
|
|
|
public function view(): View
|
|
{
|
|
return view('export.reporteExport',[
|
|
'ventas' => Venta::whereBetween('created_at',[$this->fecha_inicio,$this->fecha_final])->get(),
|
|
]);
|
|
}
|
|
} |