0
$role = $request->id_cliente;
$data_inicial = $request->data_inicial;
$data_final = $request->data_final;
$vendasCliente = DB::table('venda')
->join('cliente', 'cliente.id_cliente', '=', 'venda.id_cliente')
->select('cliente.nome', 'venda.tipo_pagamento', 'venda.data_hora', 'venda.total_venda')
->where('data_hora' ,'>=' , $data_inicial)
->where('data_hora' ,'<=' , $data_final)
->when($role, function ($query, $role) {
return $query->where('venda.id_cliente', $role);
})
->paginate(3);
return response()->json($vendasCliente);
I have the above query in Readable but I can’t paginate the result of this query...if I use get() it brings me the return of the query without pagination and your put that paginate in the query it does not bring me the records..
Try to use
simplePaginate()
instead ofpaginate()
– Costamilam
paginate() returns some error or simply returns empty?
– Kayo Bruno