public function update(TournamentFeedRequest $request, TournamentFeed $tournament_feeds)
 {
     foreach ($request->all()['data']['attributes'] as $key => $value) {
         if (isset($tournament_feeds->{$key})) {
             $tournament_feeds->{$key} = $value;
         }
     }
     // fetch tournament
     $tournament = Tournament::findOrFail($request->all()['data']['relationships']['tournament']['data']['id']);
     $tournament_feeds->tournament_id = $tournament->id;
     $tournament_feeds->save();
     $resource = new Item($tournament_feeds, new TournamentFeedTransformer(), 'tournament-feeds');
     return $this->fractal()->createData($resource)->toJson();
 }
 public function testPatchTournamentFeeds()
 {
     // create user info and convert it to json
     $location = factory(Location::class)->create();
     $tournament = factory(Tournament::class)->create(['location_id' => $location->id]);
     $tournamentFeedObject = factory(TournamentFeed::class)->create(['tournament_id' => $tournament->id]);
     $tournamentFeedObject->title = 'My Custom Title';
     $tournamentFeedData = json_encode(['data' => ['type' => 'tournament-feeds', 'attributes' => $tournamentFeedObject->toArray(), 'relationships' => ['tournament' => ['data' => ['type' => 'tournaments', 'id' => $tournament->id]]]]]);
     $response = $this->callPatch(self::API_URL . $tournamentFeedObject->id, $tournamentFeedData);
     $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
     $this->assertNotNull($tournamentFeed = json_decode($response->getContent())->data);
     $this->assertNotEmpty($tournamentFeed->id);
     // test to make sure the user was created
     $updatedTournamentFeed = TournamentFeed::findOrFail($tournamentFeed->id);
     $this->assertEquals('My Custom Title', $updatedTournamentFeed->title);
     $this->assertEquals($updatedTournamentFeed->tournament->toArray(), $tournament->toArray());
 }