From e07867ae48eb6b50faeb898cbf147ab4c474969f Mon Sep 17 00:00:00 2001 From: Valodia Date: Tue, 7 Feb 2023 21:39:14 +0400 Subject: [PATCH] Add quietly prefixed functions --- src/Illuminate/Database/Eloquent/Model.php | 10 ++++++++++ .../Database/Eloquent/Relations/HasOneOrMany.php | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/Illuminate/Database/Eloquent/Model.php b/src/Illuminate/Database/Eloquent/Model.php index 01eaa94351af..ae460d371140 100644 --- a/src/Illuminate/Database/Eloquent/Model.php +++ b/src/Illuminate/Database/Eloquent/Model.php @@ -1083,6 +1083,16 @@ public function push() return true; } + /** + * Save the model and all of its relationships without raising any events to the parent model. + * + * @return bool + */ + public function pushQuietly() + { + return static::withoutEvents(fn () => $this->push()); + } + /** * Save the model to the database without raising any events. * diff --git a/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php b/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php index 17ec20a36206..01f0c1e563fe 100755 --- a/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php +++ b/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php @@ -364,6 +364,17 @@ public function createMany(iterable $records) return $instances; } + /** + * Create a Collection of new instances of the related model without raising any events to the parent model. + * + * @param iterable $records + * @return \Illuminate\Database\Eloquent\Collection + */ + public function createManyQuietly(iterable $records) + { + return Model::withoutEvents(fn () => $this->createMany($records)); + } + /** * Set the foreign ID for creating a related model. *