Finalizacion de la primera version del proyecto
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Exports\VentasExport;
|
||||
use App\Models\Movimiento;
|
||||
use App\Models\Venta;
|
||||
use Carbon\Carbon;
|
||||
use Livewire\Component;
|
||||
@@ -11,20 +12,31 @@ use Maatwebsite\Excel\Facades\Excel;
|
||||
class ReporteController extends Component
|
||||
{
|
||||
public $fecha_inicio, $fecha_final;
|
||||
public $fn_inicio, $fn_final;
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('venta.reporte',[
|
||||
'ventas' => Venta::whereBetween('created_at',[$this->fecha_inicio,$this->fecha_final])->get()
|
||||
'movimientos' => Movimiento::whereBetween('created_at',[$this->fn_inicio,$this->fn_final])->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function updatedFechaInicio()
|
||||
{
|
||||
$this->fn_inicio= Carbon::parse($this->fecha_inicio)->startOfDay();
|
||||
}
|
||||
|
||||
public function updatedFechaFinal()
|
||||
{
|
||||
$this->fn_final= Carbon::parse($this->fecha_final)->endOfDay();
|
||||
}
|
||||
|
||||
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');
|
||||
return Excel::download(new VentasExport($this->fn_inicio, $this->fn_final),'venta-'.Carbon::now()->format('Y-m-d').'.xlsx');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user