Skip to content

Commit df696e9

Browse files
xurshudyanValodia
andauthored
Add quietly prefixed functions (#46014)
Co-authored-by: Valodia <[email protected]>
1 parent 4b5ef9e commit df696e9

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/Illuminate/Database/Eloquent/Model.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,16 @@ public function push()
10831083
return true;
10841084
}
10851085

1086+
/**
1087+
* Save the model and all of its relationships without raising any events to the parent model.
1088+
*
1089+
* @return bool
1090+
*/
1091+
public function pushQuietly()
1092+
{
1093+
return static::withoutEvents(fn () => $this->push());
1094+
}
1095+
10861096
/**
10871097
* Save the model to the database without raising any events.
10881098
*

src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,17 @@ public function createMany(iterable $records)
364364
return $instances;
365365
}
366366

367+
/**
368+
* Create a Collection of new instances of the related model without raising any events to the parent model.
369+
*
370+
* @param iterable $records
371+
* @return \Illuminate\Database\Eloquent\Collection
372+
*/
373+
public function createManyQuietly(iterable $records)
374+
{
375+
return Model::withoutEvents(fn () => $this->createMany($records));
376+
}
377+
367378
/**
368379
* Set the foreign ID for creating a related model.
369380
*

0 commit comments

Comments
 (0)