version 1.0
This commit is contained in:
40
app/exports/VentasExport.php
Normal file
40
app/exports/VentasExport.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user