File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
src/Illuminate/Database/Query Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -2724,6 +2724,13 @@ public function orderByDesc($column)
27242724 */
27252725 public function latest ($ column = 'created_at ' , $ limit = null )
27262726 {
2727+ // If only one integer argument is passed, treat it as the limit and default the column to 'created_at'.
2728+ // This allows calling "latest(11)" instead of "latest('created_at', 11)" or "latest(limit: 11)"
2729+ if (is_null ($ limit ) && is_int ($ column )) {
2730+ $ limit = $ column ;
2731+ $ column = 'created_at ' ;
2732+ }
2733+
27272734 if (! is_null ($ limit )) {
27282735 $ this ->limit ($ limit );
27292736 }
@@ -2740,6 +2747,13 @@ public function latest($column = 'created_at', $limit = null)
27402747 */
27412748 public function oldest ($ column = 'created_at ' , $ limit = null )
27422749 {
2750+ // If only one integer argument is passed, treat it as the limit and default the column to 'created_at'.
2751+ // This allows calling "oldest(11)" instead of "oldest('created_at', 11)" or "oldest(limit: 11)"
2752+ if (is_null ($ limit ) && is_int ($ column )) {
2753+ $ limit = $ column ;
2754+ $ column = 'created_at ' ;
2755+ }
2756+
27432757 if (! is_null ($ limit )) {
27442758 $ this ->limit ($ limit );
27452759 }
You can’t perform that action at this time.
0 commit comments