28 lines
673 B
PHP
28 lines
673 B
PHP
<?php
|
|
|
|
namespace App\Actions;
|
|
|
|
use App\Enums\PaymentStatusEnum;
|
|
use App\Models\Payment;
|
|
use App\Models\PaymentStatus;
|
|
use Symfony\Component\Translation\Exception\NotFoundResourceException;
|
|
|
|
final readonly class MarkPaymentAsPaidAction
|
|
{
|
|
/**
|
|
* Execute the action.
|
|
*
|
|
* @throws NotFoundResourceException
|
|
*/
|
|
public function execute(Payment $payment): bool
|
|
{
|
|
$status = PaymentStatus::whereName(PaymentStatusEnum::Paid->value)->value('id');
|
|
if (! $status) {
|
|
throw new NotFoundResourceException('Paid Status not found');
|
|
}
|
|
$payment->payment_status_id = $status;
|
|
|
|
return $payment->save();
|
|
}
|
|
}
|