mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-25 23:43:58 +00:00
81 lines
2.4 KiB
PHP
81 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\CompanyBanks\ControllersLogic;
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllersLogic;
|
|
|
|
use App\Classes\Modules\CompanyBanks\Standards\Rules\CanCreateCompanyBank;
|
|
use App\Classes\Modules\CompanyBanks\Services\CreatesCompanyBank;
|
|
use App\Classes\Modules\CompanyBanks\DataTransferObjects\CompanyBankObject;
|
|
use App\Http\Resources\CompanyBankResource;
|
|
|
|
use ErrorException;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class CreateCompanyBankLogic extends AbstractControllersLogic
|
|
{
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Created Company Bank',
|
|
'message' => 'You have successfully created a new Company Bank'
|
|
];
|
|
}
|
|
|
|
/** @var CanCreateCompanyBank */
|
|
private $canCreateCompanyBank;
|
|
|
|
/** @var CreatesCompanyBank */
|
|
private $createsCompanyBank;
|
|
|
|
|
|
/**
|
|
* CreateCompanyBankLogic constructor.
|
|
* @param CanCreateCompanyBank $canCreateCompanyBank
|
|
* @param CreatesCompanyBank $createsCompanyBank
|
|
*/
|
|
public function __construct(
|
|
CanCreateCompanyBank $canCreateCompanyBank,
|
|
CreatesCompanyBank $createsCompanyBank
|
|
)
|
|
{
|
|
$this->canCreateCompanyBank = $canCreateCompanyBank;
|
|
$this->createsCompanyBank = $createsCompanyBank;
|
|
}
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @return JsonResponse
|
|
* @throws ErrorException
|
|
*/
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
try {
|
|
DB::beginTransaction();
|
|
|
|
$company_bank_object = new CompanyBankObject(
|
|
$request->input('country_id'),
|
|
$request->input('company_id'),
|
|
$request->input('bank_name'),
|
|
$request->input('holder_name'),
|
|
$request->input('account_no'),
|
|
$request->input('type'),
|
|
$request->input('default')
|
|
);
|
|
$this->canCreateCompanyBank->passes($company_bank_object);
|
|
$company_bank_query = $this->createsCompanyBank->execute($company_bank_object);
|
|
|
|
DB::commit();
|
|
|
|
return $this->resourceResponse(new CompanyBankResource($company_bank_query));
|
|
|
|
} catch (\Exception $exception) {
|
|
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
|
}
|
|
|
|
}
|
|
} |