public function update(UserProfileRequest $request, UserProfile $user_profiles)
 {
     foreach ($request->all()['data']['attributes'] as $key => $value) {
         if (isset($user_profiles->{$key})) {
             $user_profiles->{$key} = $value;
         }
     }
     $user_profiles->save();
     $resource = new Item($user_profiles, new UserProfileTransformer(), 'user-profiles');
     return $this->fractal()->createData($resource)->toJson();
 }
 public function testPatchUserProfiles()
 {
     // create uesr with profile
     $user = factory(User::class)->create();
     $userProfile = factory(UserProfile::class)->create(['user_id' => $user->id]);
     $userProfileData = ['data' => ['type' => 'user-profiles', 'attributes' => $userProfile->toArray()]];
     $userProfileData['data']['attributes']['experience'] = 1900;
     $userProfileData = json_encode($userProfileData);
     $response = $this->callPatch(self::API_URL . $userProfile->id, $userProfileData);
     $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
     $this->assertNotNull($userProfileResponse = json_decode($response->getContent())->data);
     $this->assertNotEmpty($userProfileResponse->id);
     // test to make sure the user was updated
     try {
         $updatedUserProfile = UserProfile::findOrFail($userProfile->id);
         $this->assertEquals('1900', $updatedUserProfile->experience);
     } catch (Exception $e) {
         $this->assertTrue(false, 'User profile not found');
     }
 }