Extract method
This commit is contained in:
parent
e94ee48f74
commit
fc88b2487f
1 changed files with 12 additions and 8 deletions
|
@ -27,15 +27,8 @@ class CheckoutAcceptanceFactory extends Factory
|
|||
public function configure(): static
|
||||
{
|
||||
return $this->afterCreating(function (CheckoutAcceptance $acceptance) {
|
||||
// @todo: add comment
|
||||
if ($acceptance->checkoutable instanceof Asset) {
|
||||
$acceptance->checkoutable->assetlog()->create([
|
||||
'action_type' => 'checkout',
|
||||
'target_id' => $acceptance->assigned_to_id,
|
||||
'target_type' => get_class($acceptance->assignedTo),
|
||||
'item_id' => $acceptance->checkoutable_id,
|
||||
'item_type' => $acceptance->checkoutable_type,
|
||||
]);
|
||||
$this->createdAssociatedActionLogEntry($acceptance);
|
||||
}
|
||||
|
||||
if ($acceptance->checkoutable instanceof Asset && $acceptance->assignedTo instanceof User) {
|
||||
|
@ -70,4 +63,15 @@ class CheckoutAcceptanceFactory extends Factory
|
|||
'declined_at' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
private function createdAssociatedActionLogEntry(CheckoutAcceptance $acceptance): void
|
||||
{
|
||||
$acceptance->checkoutable->assetlog()->create([
|
||||
'action_type' => 'checkout',
|
||||
'target_id' => $acceptance->assigned_to_id,
|
||||
'target_type' => get_class($acceptance->assignedTo),
|
||||
'item_id' => $acceptance->checkoutable_id,
|
||||
'item_type' => $acceptance->checkoutable_type,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue