mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 12:33:56 +00:00
63 lines
2.0 KiB
PHP
63 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Companies\ControllersLogic;
|
|
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
use App\Classes\Modules\Companies\Services\UpdatesCompanyEInvoiceRequest;
|
|
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
|
use App\Classes\Modules\Companies\DataTransferObjects\EInvoiceRequestDTO;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class UpdateCompanyEInvoiceRequestChangeLogic extends AbstractControllerLogic
|
|
{
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Updated EInvoice Request',
|
|
'message' => 'You have successfully updated company E-Invoice request'
|
|
];
|
|
}
|
|
|
|
/** @var FetchesCompany */
|
|
private $fetchesCompany;
|
|
|
|
/** @var UpdatesCompanyEInvoiceRequest */
|
|
private $updatesCompanyEInvoiceRequest;
|
|
|
|
|
|
/**
|
|
* UpdateCompanyEInvoiceRequestChangeLogic constructor.
|
|
* @param FetchesCompany $fetchesCompany
|
|
* @param UpdatesCompanyEInvoiceRequest $updatesCompanyEInvoiceRequest
|
|
*/
|
|
public function __construct(FetchesCompany $fetchesCompany, UpdatesCompanyEInvoiceRequest $updatesCompanyEInvoiceRequest)
|
|
{
|
|
$this->fetchesCompany = $fetchesCompany;
|
|
$this->updatesCompanyEInvoiceRequest = $updatesCompanyEInvoiceRequest;
|
|
}
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @return JsonResponse
|
|
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
|
*/
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
$dto = new EInvoiceRequestDTO($request->all());
|
|
$company = $this->fetchesCompany->execute(['id' => $dto->companyId]);
|
|
|
|
if($company->e_invoice === 1){
|
|
$this->updatesCompanyEInvoiceRequest->execute($company, $dto->eInvoiceRequest);
|
|
}
|
|
|
|
return $this->response([]);
|
|
}
|
|
}
|