Pagination also doesn't work. All I see is the first page of results.
Using the bllim/datatables ~1.4
package for Laravel.
I've tracked it down to the following code:
$Items = Item::select([
'images.image',
'items.id',
'items.sku',
DB::raw("IF(items.enabled, 'Yes', 'No') AS enabled")
])
->leftJoin('images', function ($j) {
$j->on('items.id', '=', 'images.imageable_id')
->where('images.imageable_type', '=', 'Item');
})
->whereNull('items.deleted_at')
->groupBy('items.id');
return Datatables::of($Items)->make();
If I remove the leftJoin
and remove the images.image
field then pagination works correctly but my images don't show. The image thumbnail shows correctly when I keep the join, but that breaks pagination.
Here is my image config on the JS side (if anyone is wondering...changing/removing it does not affect pagination):
{
aTargets: [0],
bSearchable: false,
mData: "image",
mRender: function (data, type, full) {
return '<img src="' + full[0] + '" alt="thumbnail" class="img-thumbnail" />';
}
}
What might the problem be with this query?