mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-21 21:44:09 +00:00
69 lines
2.4 KiB
PHP
69 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Companies\ControllersLogic;
|
|
|
|
use App\Classes\Modules\Unity\Processors\CreateEntityProcessor;
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
use App\Classes\Modules\Companies\Processors\CreateCompanyProcessor;
|
|
use App\Classes\Modules\Companies\Processors\CreateCompanyModuleProcessor;
|
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
use App\Classes\ValueObjects\Constants\BusinessType;
|
|
use App\Classes\ValueObjects\Constants\CompanyType;
|
|
use App\Http\Resources\CompanyResource;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class CreateCompanyLogic extends AbstractControllerLogic
|
|
{
|
|
|
|
private $createUnityEntityProcessor;
|
|
|
|
/**
|
|
* CreateCompanyLogic constructor.
|
|
* @param CreateCompanyProcessor $createCompanyProcessor
|
|
* @param CreateCompanyModuleProcessor $createCompanyModuleProcessor
|
|
*/
|
|
public function __construct(CreateCompanyProcessor $createCompanyProcessor ,CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateEntityProcessor $createUnityEntityProcessor)
|
|
{
|
|
$this->createCompanyProcessor = $createCompanyProcessor;
|
|
$this->createCompanyModuleProcessor = $createCompanyModuleProcessor;
|
|
$this->createUnityEntityProcessor = $createUnityEntityProcessor;
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Created Company',
|
|
'message' => 'You have successfully created a new Company'
|
|
];
|
|
}
|
|
|
|
/** @var CreateCompanyProcessor */
|
|
private $createCompanyProcessor;
|
|
|
|
|
|
/**
|
|
* @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
|
|
{
|
|
$company = $this->createCompanyProcessor->execute($request, $request->input('type'), ApprovalStatus::PENDING_SUBMISSION);
|
|
|
|
$this->createCompanyModuleProcessor->execute($company , $request->input('business_type'));
|
|
|
|
$unityEntity = $this->createUnityEntityProcessor->execute($company->name);
|
|
|
|
//$company->unity_hash_id = $unityEntity->hash_id;
|
|
//Update company table
|
|
|
|
return $this->resourceResponse(new CompanyResource($company));
|
|
}
|
|
|
|
}
|