bgultekin / laravel4-datatables-package

Server-side handler of DataTables Jquery Plugin for Laravel 4
267 stars 108 forks source link

Incorrect count with Eloquent query including subqueries #42

Closed zillarelli closed 11 years ago

zillarelli commented 11 years ago

Whenever I run an Eloquent query that includes a subquery, the total count ends up being null and outputs as NaN. However, changing the following seems to solve the issue for me:

in the count method: $this->count_all = $this->query->count();

changed to: $this->count_all = get_class($this->query) == 'Illuminate\Database\Query\Builder' ? $this->query->count() : $this->query->get()->count();

However I'm not sure if this would be the best way but perhaps someone could look into it. Thanks.

w0rldart commented 11 years ago

I think this issue is related to this: https://github.com/bllim/laravel4-datatables-package/pull/16

MarkVaughn commented 11 years ago

this issue is possibly fixed, as the count method has been rewritten

w0rldart commented 11 years ago

So it seems! Thank you