mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 20:43:56 +00:00
65 lines
2.0 KiB
PHP
65 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Companies\ControllersLogic;
|
|
|
|
use App\Http\Resources\CompanyResource;
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
use App\Classes\Modules\Companies\DataTransferObjects\CompanyProfileObject;
|
|
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
|
use App\Classes\Modules\Companies\Services\UpdatesCompanyProfile;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class UpdateCompanyProfileLogic extends AbstractControllerLogic
|
|
{
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Update Company Details',
|
|
'message' => 'You have successfully updated the Company Details'
|
|
];
|
|
}
|
|
|
|
/** @var FetchesCompany */
|
|
private $fetchesCompany;
|
|
|
|
/** @var UpdatesCompanyProfile */
|
|
private $updatesCompanyProfile;
|
|
|
|
/**
|
|
* UpdateCompanyProfileLogic constructor.
|
|
* @param FetchesCompany $fetchesCompany
|
|
* @param UpdatesCompanyProfile $updatesCompanyProfile
|
|
*/
|
|
public function __construct(
|
|
FetchesCompany $fetchesCompany,
|
|
UpdatesCompanyProfile $updatesCompanyProfile
|
|
)
|
|
{
|
|
$this->fetchesCompany = $fetchesCompany;
|
|
$this->updatesCompanyProfile = $updatesCompanyProfile;
|
|
}
|
|
|
|
/**
|
|
* @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
|
|
{
|
|
$object = new CompanyProfileObject($request->input('email'), $request->input('phone'), $request->input('type'));
|
|
|
|
$company = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
|
|
|
$company_query = $this->updatesCompanyProfile->execute($company, $object);
|
|
|
|
return $this->resourceResponse(new CompanyResource($company_query));
|
|
|
|
}
|
|
|
|
} |