0

Error with pagination, my code:

public function index() {

     $cards1= DB::select('select rm.user_id, u.email,rm.fecha,rm.tarjeta as t1,cm.tarjeta as t2,
            cm.autorizacion as aut2, rm.autorizacion as aut1, date (cm.created_at) as creacion
            from consultas.contracargos_mediakey cm
            left join repsmediakey rm on rm.autorizacion=cm.autorizacion
            left join mediakey.users u on u.id=rm.user_id
            where right(cm.tarjeta,2)=right(rm.tarjeta,2) 
            or rm.autorizacion is null 
            order by cm.id')->paginate(15);
    return view('mediakey.index',compact('cards1'));
}

Call to a member function paginate() on array

1
  • Please edit your post for better formatting Commented Jun 11, 2019 at 0:23

1 Answer 1

1

First, I would use some select() with join() and where() and orWhere() clauses in Laravel. I'm not sure you can type all that within a select() method for DB.

If you want to input some raw query you have to use the DB::raw(<your-raw-sql-code>) within your DB::select() statement.

But I suggest you learn how to use the Laravel DB query builder to build those queries.

I guess then paginate will work.

Sign up to request clarification or add additional context in comments.

2 Comments

without paginate it works and doing the query with DB :: table I do not find how to use the right in my query
@DanielCarrilloTapia I suggest you learn how to put all that big query you did inside a select, using the DB query builder.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.