Skip to content

Commit

Permalink
Extract method
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusmoore committed Jan 30, 2025
1 parent e94ee48 commit fc88b24
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions database/factories/CheckoutAcceptanceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
]);
}
}

0 comments on commit fc88b24

Please sign in to comment.