mirror of
https://gitlab.com/uldvstar/exchange-2.0.git
synced 2026-08-19 04:24:16 +00:00
aa6f59b86d
-Update Company Bank Logic Class -Delete Company Bank Logic Class
82 lines
2.3 KiB
PHP
82 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\CompanyBanks\ControllersLogic;
|
|
|
|
use App\Http\Resources\CompanyBankResource;
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
|
|
use App\Classes\Modules\CompanyBanks\Services\FetchesCompanyBank;
|
|
|
|
use App\Classes\Modules\CompanyBanks\Standards\Rules\CanDeleteCompanyBank;
|
|
use App\Classes\Modules\CompanyBanks\Services\DeletesCompanyBank;
|
|
use App\Classes\Modules\CompanyBanks\DataTransferObjects\SegmentObject;
|
|
|
|
use ErrorException;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class DeleteCompanyBankLogic extends AbstractControllerLogic
|
|
{
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Delete Company Bank',
|
|
'message' => 'You have successfully deleted the Company Bank'
|
|
];
|
|
}
|
|
|
|
/** @var CanDeleteCompanyBank */
|
|
private $canDeleteCompanyBank;
|
|
|
|
/** @var DeletesCompanyBank */
|
|
private $deletesCompanyBank;
|
|
|
|
/** @var FetchesCompanyBank */
|
|
private $fetchesCompanyBank;
|
|
|
|
/**
|
|
* UpdateStandardSegmentConstantLogic constructor.
|
|
* @param CanUpdateSegment $canDeleteCompanyBank
|
|
* @param UpdatesSegment $deletesSegment
|
|
* @param FetchesCompanyBank $fetchesCompanyBank
|
|
*/
|
|
public function __construct(
|
|
CanDeleteCompanyBank $canDeleteCompanyBank,
|
|
DeletesCompanyBank $deletesCompanyBank,
|
|
FetchesCompanyBank $fetchesCompanyBank
|
|
)
|
|
{
|
|
$this->canDeleteCompanyBank = $canDeleteCompanyBank;
|
|
$this->deletesCompanyBank = $deletesCompanyBank;
|
|
$this->fetchesCompanyBank = $fetchesCompanyBank;
|
|
}
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @return JsonResponse
|
|
* @throws ErrorException
|
|
*/
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
try {
|
|
DB::beginTransaction();
|
|
|
|
$segment_query = $this->fetchesCompanyBank->execute(['id' => $request->route('id')]);
|
|
$this->canDeleteCompanyBank->passes();
|
|
$this->deletesCompanyBank->execute($segment_query);
|
|
|
|
DB::commit();
|
|
|
|
return $this->resourceResponse(new CompanyBankResource($segment_query));
|
|
|
|
} catch (\Exception $exception){
|
|
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
|
}
|
|
}
|
|
|
|
} |