Se agrego paginacion en reporte pedidos
This commit is contained in:
@@ -6,16 +6,26 @@ use App\Exports\PedidosExport;
|
|||||||
use App\Models\Pedido;
|
use App\Models\Pedido;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
use Livewire\WithPagination;
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
|
||||||
class ReportePedidoController extends Component
|
class ReportePedidoController extends Component
|
||||||
{
|
{
|
||||||
|
use WithPagination;
|
||||||
public $fecha_inicio, $fecha_final;
|
public $fecha_inicio, $fecha_final;
|
||||||
public $fn_inicio, $fn_final;
|
public $fn_inicio, $fn_final;
|
||||||
public $is_venta_cerrada = "", $is_venta_entregada ="";
|
public $is_venta_cerrada = "", $is_venta_entregada ="";
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
|
if(is_null($this->fecha_inicio) && is_null($this->fecha_final))
|
||||||
|
{
|
||||||
|
$this->fecha_inicio = Carbon::now()->format('Y-m-d');
|
||||||
|
$this->fecha_final = Carbon::now()->format('Y-m-d');
|
||||||
|
$this->fn_inicio= Carbon::parse($this->fecha_inicio)->startOfDay();
|
||||||
|
$this->fn_final= Carbon::parse($this->fecha_final)->endOfDay();
|
||||||
|
|
||||||
|
}
|
||||||
$query = Pedido::query();
|
$query = Pedido::query();
|
||||||
|
|
||||||
$query->when($this->is_venta_entregada, function ($query) {
|
$query->when($this->is_venta_entregada, function ($query) {
|
||||||
@@ -29,7 +39,7 @@ class ReportePedidoController extends Component
|
|||||||
return $query->whereBetween('created_at', [$this->fn_inicio, $this->fn_final]);
|
return $query->whereBetween('created_at', [$this->fn_inicio, $this->fn_final]);
|
||||||
});
|
});
|
||||||
return view('pedido.reporte-pedido',[
|
return view('pedido.reporte-pedido',[
|
||||||
'pedidos' => $query->get(),
|
'pedidos' => $query->paginate(10),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,6 +67,7 @@ class ReportePedidoController extends Component
|
|||||||
$query->when(($this->fn_inicio && $this->fn_final), function ($query) {
|
$query->when(($this->fn_inicio && $this->fn_final), function ($query) {
|
||||||
return $query->whereBetween('created_at', [$this->fn_inicio, $this->fn_final]);
|
return $query->whereBetween('created_at', [$this->fn_inicio, $this->fn_final]);
|
||||||
});
|
});
|
||||||
|
$this->resetPage();
|
||||||
|
|
||||||
return Excel::download(new PedidosExport($this->fn_inicio, $this->fn_final,$this->is_venta_cerrada,$this->is_venta_entregada),'pedido-'.Carbon::now()->format('Y-m-d').'.xlsx');
|
return Excel::download(new PedidosExport($this->fn_inicio, $this->fn_final,$this->is_venta_cerrada,$this->is_venta_entregada),'pedido-'.Carbon::now()->format('Y-m-d').'.xlsx');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,6 +97,7 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
{{$pedidos->links()}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user