31 lines
769 B
PHP
31 lines
769 B
PHP
<?php
|
|
|
|
namespace App\Http\Livewire;
|
|
|
|
use App\Exports\VentasExport;
|
|
use App\Models\Venta;
|
|
use Carbon\Carbon;
|
|
use Livewire\Component;
|
|
use Maatwebsite\Excel\Facades\Excel;
|
|
|
|
class ReporteController extends Component
|
|
{
|
|
public $fecha_inicio, $fecha_final;
|
|
|
|
public function render()
|
|
{
|
|
return view('venta.reporte',[
|
|
'ventas' => Venta::whereBetween('created_at',[$this->fecha_inicio,$this->fecha_final])->get()
|
|
]);
|
|
}
|
|
|
|
public function export()
|
|
{
|
|
$this->validate([
|
|
'fecha_inicio' => 'required|date',
|
|
'fecha_final' => 'required|date',
|
|
]);
|
|
return Excel::download(new VentasExport($this->fecha_inicio, $this->fecha_final),'venta-'.Carbon::now()->format('Y-m-d').'.xlsx');
|
|
}
|
|
}
|