Basic implementation of payment methods
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateAvailablePaymentMethod;
|
||||
|
||||
use App\Domains\Admin\Actions\RemovePaymentMethodUsage\RemovePaymentMethodUsageAction;
|
||||
|
||||
class UpdateAvailablePaymentMethodAction
|
||||
{
|
||||
public function __construct(private UpdateAvailablePaymentMethodRequest $request)
|
||||
{
|
||||
}
|
||||
|
||||
public function execute(): UpdateAvailablePaymentMethodResponse
|
||||
{
|
||||
$response = new UpdateAvailablePaymentMethodResponse();
|
||||
$wasActive = $this->request->availablePaymentMethod->active;
|
||||
|
||||
$this->request->availablePaymentMethod->update([
|
||||
'name' => $this->request->name,
|
||||
'description' => $this->request->description,
|
||||
'active' => $this->request->active,
|
||||
]);
|
||||
|
||||
if ($wasActive && !$this->request->active) {
|
||||
(new RemovePaymentMethodUsageAction())->execute($this->request->availablePaymentMethod);
|
||||
}
|
||||
|
||||
$response->success = true;
|
||||
$response->message = 'Zahlungsmethode wurde gespeichert.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateAvailablePaymentMethod;
|
||||
|
||||
use App\Models\AvailablePaymentMethod;
|
||||
|
||||
class UpdateAvailablePaymentMethodRequest
|
||||
{
|
||||
public function __construct(
|
||||
public AvailablePaymentMethod $availablePaymentMethod,
|
||||
public string $name,
|
||||
public ?string $description,
|
||||
public bool $active,
|
||||
) {
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateAvailablePaymentMethod;
|
||||
|
||||
class UpdateAvailablePaymentMethodResponse
|
||||
{
|
||||
public bool $success = false;
|
||||
public string $message = '';
|
||||
}
|
||||
Reference in New Issue
Block a user