$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 laravel but I can not paginate the result of this query ... if I use get () it brings me the return of the query without pagination and its put that paginate in the query it does not bring me the records. .