From fc88b2487ff524d6515852b9fa8224263cdba411 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 30 Jan 2025 11:44:37 -0800 Subject: [PATCH] Extract method --- .../factories/CheckoutAcceptanceFactory.php | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/database/factories/CheckoutAcceptanceFactory.php b/database/factories/CheckoutAcceptanceFactory.php index 8dbb6712c..a15e942a8 100644 --- a/database/factories/CheckoutAcceptanceFactory.php +++ b/database/factories/CheckoutAcceptanceFactory.php @@ -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, + ]); + } }