Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] minor readability #54117

Open
wants to merge 1 commit into
base: 11.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions src/Illuminate/Database/Eloquent/Factories/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,7 @@ public function createMany(int|iterable|null $records = null)
*/
public function createManyQuietly(int|iterable|null $records = null)
{
return Model::withoutEvents(function () use ($records) {
return $this->createMany($records);
});
return Model::withoutEvents(fn () => $this->createMany($records));
}

/**
Expand Down Expand Up @@ -316,9 +314,7 @@ public function create($attributes = [], ?Model $parent = null)
*/
public function createQuietly($attributes = [], ?Model $parent = null)
{
return Model::withoutEvents(function () use ($attributes, $parent) {
return $this->create($attributes, $parent);
});
return Model::withoutEvents(fn () => $this->create($attributes, $parent));
}

/**
Expand Down Expand Up @@ -472,11 +468,10 @@ protected function getRawAttributes(?Model $parent)
*/
protected function parentResolvers()
{
$model = $this->newModel();

return $this->for->map(function (BelongsToRelationship $for) use ($model) {
return $for->recycle($this->recycle)->attributesFor($model);
})->collapse()->all();
return $this->for
->map(fn (BelongsToRelationship $for) => $for->recycle($this->recycle)->attributesFor($this->newModel()))
->collapse()
->all();
}

/**
Expand Down Expand Up @@ -524,9 +519,7 @@ public function state($state)
{
return $this->newInstance([
'states' => $this->states->concat([
is_callable($state) ? $state : function () use ($state) {
return $state;
},
is_callable($state) ? $state : fn () => $state,
]),
]);
}
Expand Down
Loading