mirror of
https://gitlab.com/omair-personal/izyim.git
synced 2026-08-19 04:14:05 +00:00
54 lines
1.5 KiB
PHP
54 lines
1.5 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: mhmj
|
|
* Date: 18/07/2019
|
|
* Time: 4:46 PM
|
|
*/
|
|
|
|
namespace App\Classes\Modules\FreightForwarder\Services;
|
|
|
|
|
|
use App\Classes\Modules\ControllerLogic\Exceptions\InternalServerErrorException;
|
|
use App\Classes\Modules\FreightForwarder\DataTransferObjects\ServiceObject;
|
|
use App\Classes\ValueObjects\Constants\HttpStatus;
|
|
use App\Models\ServiceFees;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
class UpdatesServiceFees
|
|
{
|
|
/** @var ServiceFees */
|
|
private $repository;
|
|
|
|
/**
|
|
* UpdatesServiceFees constructor.
|
|
* @param ServiceFees $repository
|
|
*/
|
|
public function __construct(ServiceFees $repository)
|
|
{
|
|
$this->repository = $repository;
|
|
}
|
|
|
|
|
|
public function execute(?String $serviceId = null, ServiceObject $serviceObject){
|
|
try{
|
|
$this->repository->updateOrCreate(
|
|
[
|
|
'id' => $serviceId,
|
|
],
|
|
[
|
|
'name' => $serviceObject->getName(),
|
|
'type' => $serviceObject->getType(),
|
|
'description' => $serviceObject->getDescription(),
|
|
'cost' => $serviceObject->getCost(),
|
|
'forwarder_id' => $serviceObject->getForwarderId(),
|
|
]);
|
|
|
|
return new JsonResponse([],HttpStatus::OK);
|
|
|
|
}catch(\Exception $exception){
|
|
|
|
throw new InternalServerErrorException("Failed to update Service Fees because {$exception->getMessage()}");
|
|
}
|
|
}
|
|
} |