Level 1
found a solution.
->addBinding($userId, 'select')
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have Eloquent query with joins and conditions. The problem is that with this line, my query works weird:
$query->addSelect(DB::raw("IF(news.user_id= ? , 1, 0) as edit"))->addBinding($userId);
$query->get(); // returns collection of 27 items
$query->paginate(15); // returns empty collection
$query->simplePaginate(15); // returns collection of 15 items
can someone explain why this is happening with paginate()? Any solutions to get correctly paginate()?
found a solution.
->addBinding($userId, 'select')
Please or to participate in this conversation.