'Updated PackingList', 'message' => 'You have successfully updated the PackingList' ]; } /** @var CanUpdatePackingList */ private $canUpdatePackingList; /** @var UpdatesPackingList */ private $updatesPackingList; /** @var FetchesPackingList */ private $fetchesPackingList; /** @var FetchesDistrict */ private $fetchesDistrict; /** * UpdatePackingListLogic constructor. * @param CanUpdatePackingList $canUpdatePackingList * @param UpdatesPackingList $updatesPackingList * @param FetchesPackingList $fetchesPackingList * @param FetchesDistrict $fetchesDistrict */ public function __construct(CanUpdatePackingList $canUpdatePackingList, UpdatesPackingList $updatesPackingList, FetchesPackingList $fetchesPackingList, FetchesDistrict $fetchesDistrict) { $this->canUpdatePackingList = $canUpdatePackingList; $this->updatesPackingList = $updatesPackingList; $this->fetchesPackingList = $fetchesPackingList; $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 PackingListObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code')); //$object = new PackingListObject($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->canUpdatePackingList->passes($object); $query = $this->fetchesPackingList->execute(['id' => $request->route('id')]); $query = $this->updatesPackingList->execute($query, $object); return $this->resourceResponse(new PackingListResource($query)); } catch (\Exception $exception){ throw new ErrorException($exception->getMessage(), $exception->getCode()); } } }