Files
izyim/app/Classes/Modules/ControllersLogic/FreightForwarder/UpdateServiceFeesLogic.php
T
2019-07-18 17:36:36 +08:00

45 lines
1.3 KiB
PHP

<?php
/**
* Created by PhpStorm.
* User: mhmj
* Date: 18/07/2019
* Time: 4:45 PM
*/
namespace App\Classes\Modules\ControllersLogic\FreightForwarder;
use App\Classes\Modules\ControllerLogic\Exceptions\InternalServerErrorException;
use App\Classes\Modules\FreightForwarder\DataTransferObjects\ServiceObject;
use App\Classes\Modules\FreightForwarder\Services\UpdatesServiceFees;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class UpdateServiceFeesLogic
{
/** @var UpdatesServiceFees */
private $updatesServiceFees;
/**
* UpdateServiceFeesLogic constructor.
* @param UpdatesServiceFees $updatesServiceFees
*/
public function __construct(UpdatesServiceFees $updatesServiceFees)
{
$this->updatesServiceFees = $updatesServiceFees;
}
public function execute(Request $request){
try{
$object = new ServiceObject($request->input('type'), $request->input('forwarder_id'), $request->input('name'), $request->input('description'), $request->input('cost'));
return $this->updatesServiceFees->execute($request->input('id'), $object);
return new JsonResponse([],HttpStatus::REQUEST_ACCEPTED);
}catch (\Exception $exception){
throw new InternalServerErrorException("Failed to update Service Fees because{$exception->getMessage()}");
}
}
}