'Updated ContainerPackingList', 'message' => 'You have successfully updated the ContainerPackingList' ]; } /** @var CanUpdateContainerPackingList */ private $canUpdateContainerPackingList; /** @var UpdatesContainerPackingList */ private $updatesContainerPackingList; /** @var FetchesContainerPackingList */ private $fetchesContainerPackingList; /** @var FetchesDistrict */ private $fetchesDistrict; /** * UpdateContainerPackingListLogic constructor. * @param CanUpdateContainerPackingList $canUpdateContainerPackingList * @param UpdatesContainerPackingList $updatesContainerPackingList * @param FetchesContainerPackingList $fetchesContainerPackingList * @param FetchesDistrict $fetchesDistrict */ public function __construct(CanUpdateContainerPackingList $canUpdateContainerPackingList, UpdatesContainerPackingList $updatesContainerPackingList, FetchesContainerPackingList $fetchesContainerPackingList, FetchesDistrict $fetchesDistrict) { $this->canUpdateContainerPackingList = $canUpdateContainerPackingList; $this->updatesContainerPackingList = $updatesContainerPackingList; $this->fetchesContainerPackingList = $fetchesContainerPackingList; $this->fetchesDistrict = $fetchesDistrict; } /** * @param Request $request * @return JsonResponse * @throws ErrorException */ public function logic(Request $request) : JsonResponse { try { $district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]); $object = new ContainerPackingListObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code')); //$object = new ContainerPackingListObject($request->input('company_id'), $request->input('street_one'), $request->input('street_two'), $request->input('city'), $request->input('state'), $request->input('post_code'), $request->input('country'), $request->input('default'), $request->input('billing')); $this->canUpdateContainerPackingList->passes($object); $query = $this->fetchesContainerPackingList->execute(['id' => $request->route('id')]); $query = $this->updatesContainerPackingList->execute($query, $object); return $this->resourceResponse(new ContainerPackingListResource($query)); } catch (\Exception $exception){ throw new ErrorException($exception->getMessage(), $exception->getCode()); } } }