diff --git a/database/factories/CheckoutAcceptanceFactory.php b/database/factories/CheckoutAcceptanceFactory.php index 8dbb6712c6f..a15e942a847 100644 --- a/database/factories/CheckoutAcceptanceFactory.php +++ b/database/factories/CheckoutAcceptanceFactory.php @@ -27,15 +27,8 @@ public function definition() 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 @@ public function accepted() '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, + ]); + } }