mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 12:33:56 +00:00
66 lines
1.9 KiB
PHP
66 lines
1.9 KiB
PHP
<?php
|
|
namespace App\Classes\Modules\Companies\ControllersLogic;
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
use App\Classes\Modules\Companies\Services\UpdatesCompanyDebtor;
|
|
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
|
use App\Classes\Modules\Companies\Standards\Rules\CanUpdateCompany;
|
|
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
|
use App\Http\Resources\CompanyResource;
|
|
use ErrorException;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class UpdateCompanyDebtorLogic extends AbstractControllerLogic
|
|
{
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Updated Company',
|
|
'message' => 'You have successfully updated the Company'
|
|
];
|
|
}
|
|
|
|
/** @var CanUpdateCompany */
|
|
private $canUpdateCompany;
|
|
|
|
/** @var UpdatesCompanyDebtor */
|
|
private $updatesCompanyDebtor;
|
|
|
|
/** @var FetchesCompany */
|
|
private $fetchesCompany;
|
|
|
|
/**
|
|
* UpdateCompanyControllersLogic constructor.
|
|
* @param CanUpdateCompany $canUpdateCompany
|
|
* @param UpdatesCompanyDebtor $updatesCompanyDebtor
|
|
* @param FetchesCompany $fetchesCompany
|
|
*/
|
|
public function __construct(CanUpdateCompany $canUpdateCompany, UpdatesCompanyDebtor $updatesCompanyDebtor, FetchesCompany $fetchesCompany)
|
|
{
|
|
$this->canUpdateCompany = $canUpdateCompany;
|
|
$this->updatesCompanyDebtor = $updatesCompanyDebtor;
|
|
$this->fetchesCompany = $fetchesCompany;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @return JsonResponse
|
|
* @throws ErrorException
|
|
*/
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
$debtor = $request->input('debtor');
|
|
|
|
$query = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
|
|
|
$query = $this->updatesCompanyDebtor->execute($query, $debtor);
|
|
|
|
return $this->resourceResponse(new CompanyResource($query));
|
|
}
|
|
|
|
} |