From db3fe1b9492d4266b1611c79848d6bfb88c3981e Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 10 Apr 2024 09:41:04 -0500 Subject: [PATCH 1/5] fix chunkByIdDesc --- .../Eloquent/Relations/HasManyThrough.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php b/src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php index b0b4b1fdebe1..78ac9018bdd0 100644 --- a/src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php +++ b/src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php @@ -600,6 +600,24 @@ public function chunkById($count, callable $callback, $column = null, $alias = n return $this->prepareQueryBuilder()->chunkById($count, $callback, $column, $alias); } + /** + * Chunk the results of a query by comparing IDs in descending order. + * + * @param int $count + * @param callable $callback + * @param string|null $column + * @param string|null $alias + * @return bool + */ + public function chunkByIdDesc($count, callable $callback, $column = null, $alias = null) + { + $column ??= $this->getRelated()->getQualifiedKeyName(); + + $alias ??= $this->getRelated()->getKeyName(); + + return $this->prepareQueryBuilder()->chunkByIdDesc($count, $callback, $column, $alias); + } + /** * Execute a callback over each item while chunking by ID. * From 4eadc6c93f879916d7614dd5a62831d32834c639 Mon Sep 17 00:00:00 2001 From: driesvints Date: Wed, 10 Apr 2024 14:47:03 +0000 Subject: [PATCH 2/5] Update version to v10.48.6 --- src/Illuminate/Foundation/Application.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index 9649f34af55b..1aa5d18bb8ac 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -40,7 +40,7 @@ class Application extends Container implements ApplicationContract, CachesConfig * * @var string */ - const VERSION = '10.48.5'; + const VERSION = '10.48.6'; /** * The base path for the Laravel installation. From ae6dc85bf7697e0dba225704800b2140dc3971d0 Mon Sep 17 00:00:00 2001 From: driesvints Date: Wed, 10 Apr 2024 14:49:13 +0000 Subject: [PATCH 3/5] Update CHANGELOG --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c52d6040c23e..03bbdc08f3f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Release Notes for 10.x -## [Unreleased](https://github.com/laravel/framework/compare/v10.48.5...10.x) +## [Unreleased](https://github.com/laravel/framework/compare/v10.48.6...10.x) + +## [v10.48.6](https://github.com/laravel/framework/compare/v10.48.5...v10.48.6) - 2024-04-10 + +* [10.x] Added eachById and chunkByIdDesc to BelongsToMany by [@lonnylot](https://github.com/lonnylot) in https://github.com/laravel/framework/pull/50991 ## [v10.48.5](https://github.com/laravel/framework/compare/v10.48.4...v10.48.5) - 2024-04-09 From 95ef230339b15321493a08327f250c0760c95376 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 10 Apr 2024 09:54:00 -0500 Subject: [PATCH 4/5] fix more query builder methods --- .../Eloquent/Relations/BelongsToMany.php | 23 +++++++++++++++++++ .../Eloquent/Relations/HasManyThrough.php | 17 ++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php b/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php index 73152d7e5879..0f93ee7e390c 100755 --- a/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php +++ b/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php @@ -1115,6 +1115,29 @@ public function lazyById($chunkSize = 1000, $column = null, $alias = null) }); } + /** + * Query lazily, by chunking the results of a query by comparing IDs in descending order. + * + * @param int $chunkSize + * @param string|null $column + * @param string|null $alias + * @return \Illuminate\Support\LazyCollection + */ + public function lazyByIdDesc($chunkSize = 1000, $column = null, $alias = null) + { + $column ??= $this->getRelated()->qualifyColumn( + $this->getRelatedKeyName() + ); + + $alias ??= $this->getRelatedKeyName(); + + return $this->prepareQueryBuilder()->lazyByIdDesc($chunkSize, $column, $alias)->map(function ($model) { + $this->hydratePivotRelation([$model]); + + return $model; + }); + } + /** * Get a lazy collection for the given query. * diff --git a/src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php b/src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php index 78ac9018bdd0..20c34749efba 100644 --- a/src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php +++ b/src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php @@ -692,6 +692,23 @@ public function lazyById($chunkSize = 1000, $column = null, $alias = null) return $this->prepareQueryBuilder()->lazyById($chunkSize, $column, $alias); } + /** + * Query lazily, by chunking the results of a query by comparing IDs in descending order. + * + * @param int $chunkSize + * @param string|null $column + * @param string|null $alias + * @return \Illuminate\Support\LazyCollection + */ + public function lazyByIdDesc($chunkSize = 1000, $column = null, $alias = null) + { + $column ??= $this->getRelated()->getQualifiedKeyName(); + + $alias ??= $this->getRelated()->getKeyName(); + + return $this->prepareQueryBuilder()->lazyByIdDesc($chunkSize, $column, $alias); + } + /** * Prepare the query builder for query execution. * From 118c686992f4b90d4da6deaf0901315c337bbaf9 Mon Sep 17 00:00:00 2001 From: driesvints Date: Wed, 10 Apr 2024 14:57:20 +0000 Subject: [PATCH 5/5] Update version to v10.48.7 --- src/Illuminate/Foundation/Application.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index 1aa5d18bb8ac..f8db2b718375 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -40,7 +40,7 @@ class Application extends Container implements ApplicationContract, CachesConfig * * @var string */ - const VERSION = '10.48.6'; + const VERSION = '10.48.7'; /** * The base path for the Laravel installation.