Skip to content

Commit 803b4f7

Browse files
committed
Improve code formatting in bulk state transition action
1 parent 1fde7d8 commit 803b4f7

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/Actions/StateFusionBulkAction.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,21 @@ protected function setUp(): void
2929
$this->setActionAttributes();
3030
$this->action(function (Collection $records, $data) {
3131
if (empty($data)) {
32-
$records->each(fn ($record) => ($record->{$this->getAttribute()}?->equals($this->getFromState())
33-
&& in_array($this->getToState()::getMorphClass(), $record->{$this->getAttribute()}->transitionableStates())) ? $record->{$this->getAttribute()}->transitionTo($this->getToStateClass()) : null);
32+
$records->each(fn ($record) => $record->{$this->getAttribute()}?->equals($this->getFromState())
33+
&& in_array(
34+
$this->getToState()::getMorphClass(),
35+
$record->{$this->getAttribute()}->transitionableStates(),
36+
)
37+
? $record->{$this->getAttribute()}->transitionTo($this->getToStateClass())
38+
: null);
3439
} else {
35-
$records->each(fn ($record) => ($record->{$this->getAttribute()}?->equals($this->getFromState())
36-
&& in_array($this->getToState()::getMorphClass(), $record->{$this->getAttribute()}->transitionableStates())) ? $record->{$this->getAttribute()}->transitionTo($this->getToStateClass(), $data[array_key_first($data)]) : null);
40+
$records->each(fn ($record) => $record->{$this->getAttribute()}?->equals($this->getFromState())
41+
&& in_array(
42+
$this->getToState()::getMorphClass(),
43+
$record->{$this->getAttribute()}->transitionableStates(),
44+
)
45+
? $record->{$this->getAttribute()}->transitionTo($this->getToStateClass(), $data)
46+
: null);
3747
}
3848
});
3949
}

0 commit comments

Comments
 (0)