Skip to content

Commit

Permalink
Allow us to limit the amount of returned results
Browse files Browse the repository at this point in the history
  • Loading branch information
micah eschbacher committed Apr 30, 2015
1 parent 86e4803 commit 58b91cd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/MindOfMicah/LaravelDatatables/Datatable.php
Expand Up @@ -9,7 +9,7 @@ class Datatable
protected $columns;

public function __construct($a) {
$this->a = $a;
$this->a = $a;
}

public function asJsonResponse()
Expand All @@ -21,9 +21,13 @@ public function asJsonResponse()
if ($this->columns) {

}
$models = $model_name::select($this->columns?:'*')->get();
$sql = $model_name::query()->select($this->columns ?: '*');

$total = ($sql->count());
$models = $sql->take($this->a->input('length'))->get();
$data = $models->toArray();
$total = count($models);

$total = $total;
$amount_displayed = count($models);
}

Expand Down

0 comments on commit 58b91cd

Please sign in to comment.