use App\Models\User; function updateUser($userId, $updatedData) { $user = User::find($userId); $user->name = $updatedData['name']; $user->email = $updatedData['email']; $user->save(); }In this example, we first find the user in the database using the user ID. We then update the user's name and email with the data provided in the $updatedData array. Finally, we save the changes to the database. Overall, the updateUser function is a common and essential part of any PHP application that requires user management.