getUser($request); $short_url = \ShortUrl::find($args['id']); if (!$short_url) { throw new RecordNotFoundException(); } if (!Authority::canUpdateShortUrl($user, $short_url)) { throw new AuthorizationFailedException(); } $json = $this->validate($request); $short_url->alias = $json['data']['attributes']['alias']; $short_url->title = $json['data']['attributes']['title']; $short_url->store(); return $this->getContentResponse($short_url); } protected function validateResourceDocument($json, $data) { if (!self::arrayHas($json, 'data.attributes.alias')) { return 'No alias for the short-url defined'; } if (!self::arrayHas($json, 'data.attributes.title')) { return 'No title for the link target defined'; } return null; } }