Skip to content

Commit 4f80389

Browse files
committed
Fixes #1928
1 parent 4271f77 commit 4f80389

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/QueryDataTable.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,17 @@ protected function filteredCount()
210210
*/
211211
public function count()
212212
{
213-
return $this->prepareCountQuery()->count();
213+
$builder = $this->prepareCountQuery();
214+
215+
if (empty($builder->havings)) {
216+
return $builder->count();
217+
}
218+
219+
$table = $this->connection->raw('('.$builder->toSql().') count_row_table');
220+
221+
return $this->connection->table($table)
222+
->setBindings($builder->getBindings())
223+
->count();
214224
}
215225

216226
/**

0 commit comments

Comments
 (0)