Paginate query in Windows using DB::table

Asked

Viewed 22 times

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 of paginate()

  • paginate() returns some error or simply returns empty?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.