Ejemplo n.º 1
0
 public function testPatchTeams()
 {
     // create user info and convert it to json
     $teamObject = factory(Team::class)->create();
     $teamObject->name = 'teamtastic';
     $teamData = json_encode(['data' => ['type' => 'teams', 'attributes' => $teamObject->toArray()]]);
     $response = $this->callPatch(self::API_URL . $teamObject->id, $teamData);
     $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
     $this->assertNotNull($team = json_decode($response->getContent())->data);
     $this->assertNotEmpty($team->id);
     // test to make sure the user was created
     $updatedTeam = Team::findOrFail($team->id);
     $this->assertEquals('teamtastic', $updatedTeam->name);
 }
 public function update(TeamMemberRequest $request, TeamMember $team_members)
 {
     $data = $request->all();
     foreach ($data['data']['attributes'] as $key => $value) {
         if (isset($team_members->{$key})) {
             $team_members->{$key} = $value;
         }
     }
     // fetch team
     $team = Team::findOrFail($data['data']['relationships']['team']['data']['id']);
     $team_members->team_id = $team->id;
     // fetch user
     $user = User::findOrFail($data['data']['relationships']['user']['data']['id']);
     $team_members->user_id = $user->id;
     $team_members->save();
     $resource = new Item($team_members, new TeamMemberTransformer(), 'team-members');
     return $this->fractal()->createData($resource)->toJson();
 }
Ejemplo n.º 3
0
 public function destroy(Team $teams)
 {
     $teams->delete();
     return response()->json('', Response::HTTP_NO_CONTENT);
 }