diff --git a/src/Illuminate/Database/Query/Builder.php b/src/Illuminate/Database/Query/Builder.php index cc5ae7ad0b56..6ad687bd6983 100755 --- a/src/Illuminate/Database/Query/Builder.php +++ b/src/Illuminate/Database/Query/Builder.php @@ -547,6 +547,24 @@ public function where($column, $operator = null, $value = null, $boolean = 'and' return $this; } + /** + * Adds an id limit to assist with Eloquent chunkById. + * Subsequent calls override existing limit. + * + * @param string $column + * @param integer $value + */ + protected function chunkIdWhere($column, $value) + { + $where = compact('column', 'value'); + $where['type'] = 'Basic'; + $where['operator'] = '>'; + $where['boolean'] = 'and'; + $this->wheres['chunkId'] = $where; + + return $this; + } + /** * Add an array of where clauses to the query. * @@ -1498,9 +1516,9 @@ public function forPageAfterId($perPage = 15, $lastId = 0, $column = 'id') return $order['column'] === $column; })->values()->all(); - return $this->where($column, '>', $lastId) - ->orderBy($column, 'asc') - ->take($perPage); + return $this->chunkIdWhere($column, $lastId) + ->orderBy($column, 'asc') + ->take($perPage); } /**