'Updated Contact', 'message' => 'You have successfully updated the Contact' ]; } /** @var UpdatesContact */ private $updatesContact; /** @var FetchesContact */ private $fetchesContact; /** * UpdateContactLogic constructor. * @param UpdatesContact $updatesContact * @param FetchesContact $fetchesContact */ public function __construct(UpdatesContact $updatesContact, FetchesContact $fetchesContact) { $this->updatesContact = $updatesContact; $this->fetchesContact = $fetchesContact; } /** * @param Request $request * @return JsonResponse * @throws ErrorException */ public function logic(Request $request) : JsonResponse { $object = new ContactObject( $request->input('reference'), $request->input('phone'), $request->input('email'), $request->input('wechat_id') ); // $this->canUpdateContact->passes($object); $query = $this->fetchesContact->execute(['id' => $request->route('id')]); $query = $this->updatesContact->execute($query, $object); /*uniformity*/ /* return fractal() ->item($query, new ContactTransformer()) ->parseIncludes('remark') ->respond(200, [], JSON_PRETTY_PRINT);*/ return $this->resourceResponse(new ContactResource($query)); } }