Skip to content

Commit 7c338af

Browse files
authored
[9.x]: add and use arrow functions for some methods (#43447)
1 parent a9bd0ce commit 7c338af

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/Illuminate/Database/Eloquent/Concerns/HasEvents.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ public static function deleted($callback)
338338
}
339339

340340
/**
341-
* Remove all of the event listeners for the model.
341+
* Remove all the event listeners for the model.
342342
*
343343
* @return void
344344
*/

src/Illuminate/Database/Eloquent/Model.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,7 @@ public function fill(array $attributes)
448448
*/
449449
public function forceFill(array $attributes)
450450
{
451-
return static::unguarded(function () use ($attributes) {
452-
return $this->fill($attributes);
453-
});
451+
return static::unguarded(fn () => $this->fill($attributes));
454452
}
455453

456454
/**
@@ -987,9 +985,7 @@ public function push()
987985
*/
988986
public function saveQuietly(array $options = [])
989987
{
990-
return static::withoutEvents(function () use ($options) {
991-
return $this->save($options);
992-
});
988+
return static::withoutEvents(fn () => $this->save($options));
993989
}
994990

995991
/**
@@ -1301,6 +1297,16 @@ public function delete()
13011297
return true;
13021298
}
13031299

1300+
/**
1301+
* Delete the model from the database without raising any events.
1302+
*
1303+
* @return bool
1304+
*/
1305+
public function deleteQuietly()
1306+
{
1307+
return static::withoutEvents(fn () => $this->delete());
1308+
}
1309+
13041310
/**
13051311
* Delete the model from the database within a transaction.
13061312
*
@@ -1627,9 +1633,7 @@ public function replicate(array $except = null)
16271633
*/
16281634
public function replicateQuietly(array $except = null)
16291635
{
1630-
return static::withoutEvents(function () use ($except) {
1631-
return $this->replicate($except);
1632-
});
1636+
return static::withoutEvents(fn () => $this->replicate($except));
16331637
}
16341638

16351639
/**

0 commit comments

Comments
 (0)