Skip to content
This repository has been archived by the owner on Nov 18, 2024. It is now read-only.

Commit

Permalink
Update UserController.php
Browse files Browse the repository at this point in the history
  • Loading branch information
khylpe committed May 6, 2024
1 parent 9e6df7d commit 46600b1
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions backend/app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -881,13 +881,20 @@ public function editUserData(Request $request)
}

// Mettre à jour les champs modifiables de l'utilisateur avec les nouvelles valeurs
$user->fill($request->only([
'lastName', 'firstName', 'email', 'isEmailVerified', 'country', 'city', 'postalCode'
]));

// Sauvegarder les modifications de l'utilisateur
$user->save();
//! Ce code ne marche pas, probablement car les noms ne matchent pas avec la DB. Le client envoie un champ "lastName" mais le champs de la DB est last_name
// $user->fill($request->only([
// 'lastName', 'firstName', 'email', 'isEmailVerified', 'country', 'city', 'postalCode'
// ]));


// * Exemple de code
$user->last_name = $request->input('lastName', $user->last_name);
$user->first_name = $request->input('firstName', $user->first_name);
$user->email = $request->input('email', $user->email);

// TODO: Do all the other fields
$user->save();
DB::commit();

// Retourner une réponse JSON avec un message de succès et les données utilisateur mises à jour
Expand Down

0 comments on commit 46600b1

Please sign in to comment.