Skip to content

Commit

Permalink
change to put
Browse files Browse the repository at this point in the history
Signed-off-by: Valentin Sickert <[email protected]>
  • Loading branch information
Lapotor committed Dec 13, 2023
1 parent 506002b commit 3a50530
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public function show(User $user)
public function update(Request $request, User $user)
{
$validated = $request->validate([
'name' => 'sometimes|required|string',
'email' => "sometimes|required|email|unique:users,email",
'name' => 'required|string',
'email' => 'required|email|unique:users,email',
'password' => 'sometimes|required|min:8|confirmed',
]);

Expand Down
2 changes: 1 addition & 1 deletion routes/api/v1/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
Route::get('/users', [UserController::class, 'index'])->name('api.v1.users.index');
Route::post('/users', [UserController::class, 'store'])->name('api.v1.users.store');
Route::get('/users/{user}', [UserController::class, 'show'])->name('api.v1.users.show');
Route::patch('/users/{user}', [UserController::class, 'update'])->name('api.v1.users.update');
Route::put('/users/{user}', [UserController::class, 'update'])->name('api.v1.users.update');
Route::delete('/users/{user}', [UserController::class, 'destroy'])->name('api.v1.users.destroy');
});
2 changes: 1 addition & 1 deletion tests/Feature/Http/Controllers/UserControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function test_users_update(): void
$newUserData = array_merge($user->toArray(), $userData);

// Send a PATCH request to the update endpoint
$response = $this->patch('/api/v1/users/' . $user->id, $userData);
$response = $this->put('/api/v1/users/' . $user->id, $userData);

// Assert that the response has a successful status code
$response->assertStatus(200);
Expand Down

0 comments on commit 3a50530

Please sign in to comment.