diff --git a/src/Illuminate/Database/Query/Builder.php b/src/Illuminate/Database/Query/Builder.php index 0da469faa8bb..aa0cf06a0ed7 100755 --- a/src/Illuminate/Database/Query/Builder.php +++ b/src/Illuminate/Database/Query/Builder.php @@ -2456,11 +2456,12 @@ public function forPage($page, $perPage = 15) * * @param int $perPage * @param int|null $lastId - * @param string $column + * @param string|null $column * @return $this */ - public function forPageBeforeId($perPage = 15, $lastId = 0, $column = 'id') + public function forPageBeforeId($perPage = 15, $lastId = 0, $column = null) { + $column ??= $this->defaultKeyName(); $this->orders = $this->removeExistingOrdersFor($column); if (! is_null($lastId)) { @@ -2476,11 +2477,12 @@ public function forPageBeforeId($perPage = 15, $lastId = 0, $column = 'id') * * @param int $perPage * @param int|null $lastId - * @param string $column + * @param string|null $column * @return $this */ - public function forPageAfterId($perPage = 15, $lastId = 0, $column = 'id') + public function forPageAfterId($perPage = 15, $lastId = 0, $column = null) { + $column ??= $this->defaultKeyName(); $this->orders = $this->removeExistingOrdersFor($column); if (! is_null($lastId)) { @@ -2655,7 +2657,7 @@ public function toRawSql() */ public function find($id, $columns = ['*']) { - return $this->where('id', '=', $id)->first($columns); + return $this->where($this->defaultKeyName(), '=', $id)->first($columns); } /**