diff --git a/app/Classes/Modules/Companies/ControllersLogic/ListBusinessTypesLogic.php b/app/Classes/Modules/Companies/ControllersLogic/ListBusinessTypesLogic.php new file mode 100644 index 00000000..fc39d1ec --- /dev/null +++ b/app/Classes/Modules/Companies/ControllersLogic/ListBusinessTypesLogic.php @@ -0,0 +1,44 @@ + 'Retrieved Business Types', + 'message' => 'You have successfully retrieved a list of Business Types' + ]; + } + + + /** + * @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 + { + $businessTypes = []; + + foreach(BusinessType::BUSINESS_TYPE_LIST as $key => $val) { + $type = (object)["id" => $key, "type" => $val]; + array_push($businessTypes, $type); + } + + return $this->collectionResponse(BusinessTypeResource::collection($businessTypes)); + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyProfileLogic.php b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyProfileLogic.php new file mode 100644 index 00000000..ddc4fd08 --- /dev/null +++ b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyProfileLogic.php @@ -0,0 +1,65 @@ + 'Update Company Account Profile', + 'message' => 'You have successfully updated the Company Account Profile' + ]; + } + + /** @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('business_type')); + + $company = $this->fetchesCompany->execute(['id' => $request->route('id')]); + + $company_query = $this->updatesCompanyProfile->execute($company, $object); + + return $this->resourceResponse(new CompanyResource($company_query)); + + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Companies/DataTransferObjects/CompanyProfileObject.php b/app/Classes/Modules/Companies/DataTransferObjects/CompanyProfileObject.php new file mode 100644 index 00000000..99c57f93 --- /dev/null +++ b/app/Classes/Modules/Companies/DataTransferObjects/CompanyProfileObject.php @@ -0,0 +1,55 @@ +email = $email; + $this->phone = $phone; + $this->businessType = $businessType; + } + + /** + * @return string + */ + public function getEmail(): string + { + return $this->email; + } + + /** + * @return string + */ + public function getPhone(): string + { + return $this->phone; + } + + /** + * @return int + */ + public function getBusinessType(): int + { + return $this->businessType; + } +} diff --git a/app/Classes/Modules/Companies/Services/UpdatesCompanyProfile.php b/app/Classes/Modules/Companies/Services/UpdatesCompanyProfile.php new file mode 100644 index 00000000..498f859d --- /dev/null +++ b/app/Classes/Modules/Companies/Services/UpdatesCompanyProfile.php @@ -0,0 +1,32 @@ +business_type = $object->getBusinessType(); + + if ($model->contacts) { + $contact = $model->contacts()->first(); + $contact->email = $object->getEmail(); + $contact->phone = $object->getPhone(); + $contact->save(); + } + + return $this->handler($model); + + } +} \ No newline at end of file diff --git a/app/Classes/ValueObjects/Constants/BusinessType.php b/app/Classes/ValueObjects/Constants/BusinessType.php index 8cd4aa7c..69ea3202 100644 --- a/app/Classes/ValueObjects/Constants/BusinessType.php +++ b/app/Classes/ValueObjects/Constants/BusinessType.php @@ -13,10 +13,10 @@ final class BusinessType { public const TRANSFER_AGENT = 4; public const BUSINESS_TYPE_LIST = [ - self::FREIGHT_FORWARDER => 'FREIGHT_FORWARDER', - self::IMPORTER => 'IMPORTER', - self::CURRENCY_VENDOR => 'CURRENCY_VENDOR', - self::TRANSFER_AGENT => 'TRANSFER_AGENT', + self::FREIGHT_FORWARDER => 'Freight Forwarder', + self::IMPORTER => 'Importer', + self::CURRENCY_VENDOR => 'Currency Vendor', + self::TRANSFER_AGENT => 'Transfer Agent', ]; } diff --git a/app/Http/Controllers/Companies/ListBusinessTypesController.php b/app/Http/Controllers/Companies/ListBusinessTypesController.php new file mode 100644 index 00000000..ecf1f0c9 --- /dev/null +++ b/app/Http/Controllers/Companies/ListBusinessTypesController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/Companies/UpdateCompanyProfileController.php b/app/Http/Controllers/Companies/UpdateCompanyProfileController.php new file mode 100644 index 00000000..0ec9a688 --- /dev/null +++ b/app/Http/Controllers/Companies/UpdateCompanyProfileController.php @@ -0,0 +1,21 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/app/Http/Resources/BusinessTypeResource.php b/app/Http/Resources/BusinessTypeResource.php new file mode 100644 index 00000000..18e73753 --- /dev/null +++ b/app/Http/Resources/BusinessTypeResource.php @@ -0,0 +1,22 @@ + $this->id, + 'type' => $this->type, + ]; + } +} diff --git a/resources/assets/vue/components/companies/forms/EditCustomerProfileInfoFormComponent.vue b/resources/assets/vue/components/companies/forms/EditCustomerProfileInfoFormComponent.vue index 21eb294a..11447285 100644 --- a/resources/assets/vue/components/companies/forms/EditCustomerProfileInfoFormComponent.vue +++ b/resources/assets/vue/components/companies/forms/EditCustomerProfileInfoFormComponent.vue @@ -10,9 +10,9 @@