mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim.git
synced 2026-08-25 23:43:56 +00:00
53 lines
1.4 KiB
PHP
53 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: mhmj
|
|
* Date: 23/07/2019
|
|
* Time: 10:40 AM
|
|
*/
|
|
|
|
namespace App\Classes\Modules\FreightForwarder\Services;
|
|
|
|
|
|
use App\Classes\Modules\ControllerLogic\Exceptions\InternalServerErrorException;
|
|
use App\Classes\Modules\FreightForwarder\DataTransferObjects\CustomerRelationObject;
|
|
use App\Models\CustomerRelation;
|
|
|
|
class ListsCustomerRelation
|
|
{
|
|
/** @var CustomerRelation */
|
|
private $repository;
|
|
|
|
/**
|
|
* ListsCustomerRelation constructor.
|
|
* @param CustomerRelation $repository
|
|
*/
|
|
public function __construct(CustomerRelation $repository)
|
|
{
|
|
$this->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()}");
|
|
}
|
|
|
|
}
|
|
} |