feat: updates
This commit is contained in:
28
app/Actions/Account/StoreAccount.php
Normal file
28
app/Actions/Account/StoreAccount.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Account;
|
||||
|
||||
use App\Actions\BaseAction;
|
||||
use App\Commands\Account\CreateAccountCommand;
|
||||
use App\DataObjects\CreateAccountDTO;
|
||||
use Closure;
|
||||
use Exception;
|
||||
use LogicException;
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class StoreAccount extends BaseAction
|
||||
{
|
||||
public function __construct(private readonly CreateAccountCommand $createAccountCommand) {}
|
||||
|
||||
public function __invoke(CreateAccountDTO|Data $payload, Closure $next)
|
||||
{
|
||||
try {
|
||||
$payload->account = $this->createAccountCommand->execute($payload->data);
|
||||
|
||||
return $next($payload);
|
||||
|
||||
} catch (Exception $exception) {
|
||||
throw new LogicException('Error Storing Account: '.$exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
30
app/Actions/Account/StoreAccountBalance.php
Normal file
30
app/Actions/Account/StoreAccountBalance.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Account;
|
||||
|
||||
use App\Actions\BaseAction;
|
||||
use App\Commands\Account\CreateBalanceCommand;
|
||||
use App\DataObjects\CreateAccountDTO;
|
||||
use Closure;
|
||||
use Exception;
|
||||
use LogicException;
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class StoreAccountBalance extends BaseAction
|
||||
{
|
||||
public function __construct(private readonly CreateBalanceCommand $createBalanceCommand) {}
|
||||
|
||||
public function __invoke(CreateAccountDTO|Data $payload, Closure $next)
|
||||
{
|
||||
try {
|
||||
|
||||
$payload->data['account_id'] = $payload->account->id;
|
||||
$payload->balance = $this->createBalanceCommand->execute($payload->data);
|
||||
|
||||
return $next($payload->account);
|
||||
|
||||
} catch (Exception $exception) {
|
||||
throw new LogicException('Error Storing Account Balance: '.$exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,27 +5,28 @@ namespace App\Actions\Branch;
|
||||
use App\Actions\BaseAction;
|
||||
use App\Commands\Branches\CreateBranchCommand;
|
||||
use App\DataObjects\CreateBranchDTO;
|
||||
use Closure;
|
||||
use Exception;
|
||||
use LogicException;
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class StoreBranch extends BaseAction
|
||||
{
|
||||
|
||||
public function __construct(private CreateBranchCommand $createBranchCommand) {}
|
||||
public function __construct(private readonly CreateBranchCommand $createBranchCommand) {}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __invoke(CreateBranchDTO | Data $payload, \Closure $next)
|
||||
public function __invoke(CreateBranchDTO|Data $payload, Closure $next)
|
||||
{
|
||||
try {
|
||||
|
||||
$payload->branch = $this->createBranchCommand->execute($payload->data);
|
||||
|
||||
return $next($payload);
|
||||
|
||||
} catch (Exception $exception)
|
||||
{
|
||||
throw new \LogicException('Error Storing Branch: ' . $exception->getMessage());
|
||||
} catch (Exception $exception) {
|
||||
throw new LogicException('Error Storing Branch: '.$exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user