public function update(TournamentRequest $request, Tournament $tournaments) { foreach ($request->all()['data']['attributes'] as $key => $value) { if (isset($tournaments->{$key})) { $tournaments->{$key} = $value; } } // fetch location $location = Location::findOrFail($request->all()['data']['relationships']['location']['data']['id']); $tournaments->location_id = $location->id; $tournaments->save(); $resource = new Item($tournaments, new TournamentTransformer(), 'tournaments'); return $this->fractal()->createData($resource)->toJson(); }