From 951027da7f5e6ec42f0ae02776628b67f541acb1 Mon Sep 17 00:00:00 2001 From: mhmj Date: Tue, 23 Jul 2019 14:54:38 +0800 Subject: [PATCH] invoice-backend --- .../Services/ListsCustomerRelation.php | 53 +++++++++++++++++++ .../Services/ListsFreightForwarderSetting.php | 52 ++++++++++++++++++ routes/api.php | 3 +- 3 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 app/Classes/Modules/FreightForwarder/Services/ListsCustomerRelation.php create mode 100644 app/Classes/Modules/FreightForwarder/Services/ListsFreightForwarderSetting.php diff --git a/app/Classes/Modules/FreightForwarder/Services/ListsCustomerRelation.php b/app/Classes/Modules/FreightForwarder/Services/ListsCustomerRelation.php new file mode 100644 index 0000000..f34bb58 --- /dev/null +++ b/app/Classes/Modules/FreightForwarder/Services/ListsCustomerRelation.php @@ -0,0 +1,53 @@ +repository = $repository; + } + + /** + * @param int $forwarderId + * @param int $companyId + * @return CustomerRelationObject + * @throws InternalServerErrorException + */ + public function execute(int $forwarderId, int $companyId): CustomerRelationObject { + + try{ + + $repository = $this->repository->where('forwarder_id', $forwarderId)->where('company_id',$companyId)->first(); + + /** @var CustomerRelationObject $customerRelationObject */ + $customerRelationObject = new CustomerRelationObject($forwarderId, $companyId, $repository->customer_rate, $repository->wave); + + return $customerRelationObject; + + }catch (\Exception $exception){ + + throw new InternalServerErrorException("Failed to retrieve Customer Relation because{$exception->getMessage()}"); + } + + } +} \ No newline at end of file diff --git a/app/Classes/Modules/FreightForwarder/Services/ListsFreightForwarderSetting.php b/app/Classes/Modules/FreightForwarder/Services/ListsFreightForwarderSetting.php new file mode 100644 index 0000000..1896eb6 --- /dev/null +++ b/app/Classes/Modules/FreightForwarder/Services/ListsFreightForwarderSetting.php @@ -0,0 +1,52 @@ +repository = $repository; + } + + + /** + * @param int $forwarderId + * @return FreightForwarderObject + * @throws InternalServerErrorException + */ + + public function execute(int $forwarderId): FreightForwarderObject{ + + try{ + $repository = $this->repository->findOrFail($forwarderId); + + /** @var FreightForwarderObject $forwarderObject */ + $forwarderObject = new FreightForwarderObject($repository->shipping_rate, $repository->overdue_days, $repository->markup_percentage, $repository->minimum_cbm); + return $forwarderObject; + + }catch (\Exception $exception){ + throw new InternalServerErrorException("Failed to retrieve Freight Forwarder Settings because{$exception->getMessage()}"); + } + + + } +} \ No newline at end of file diff --git a/routes/api.php b/routes/api.php index db68cc4..97d3a1c 100644 --- a/routes/api.php +++ b/routes/api.php @@ -163,12 +163,11 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function // Freight Forwarder Routes Route::group(['prefix' => 'forwarder', 'as' => 'forwarder.', 'namespace' => 'FreightForwarder'], function () { - // Update Freight Forwarder Settings + // Update & Delete Route::put('/{forwarderId}/update', 'UpdateFreightForwarderController@update')->name('update.freight.forwarder'); Route::put('{companyId}/update/customer-relation', 'UpdateCustomerRelationController@update')->name('update.customer.relation'); Route::put('{forwarderId}/update/services', 'UpdateServiceFeesController@update')->name('update.service.fees'); Route::delete('/{serviceId}/delete/services', 'DeleteServiceFeesController@delete')->name('delete.service.fees'); - }); }); \ No newline at end of file