diff --git a/app/Http/Controllers/Api/ProfileController.php b/app/Http/Controllers/Api/ProfileController.php index 4101dab..375136b 100644 --- a/app/Http/Controllers/Api/ProfileController.php +++ b/app/Http/Controllers/Api/ProfileController.php @@ -179,11 +179,11 @@ class ProfileController extends Controller abort(403, 'Unauthorized'); } - $emailRule = Rule::unique('users', 'email')->ignore($profile->user_id); + // $emailRule = Rule::unique('users', 'email')->ignore($profile->user_id); $validated = $request->validate([ 'nama' => ['required', 'string', 'max:255'], - 'email' => ['required', 'email', 'max:255', $emailRule], + 'email' => ['required', 'email', 'max:255'],// $emailRule], 'telepon' => ['nullable', 'string'], 'alamat' => ['nullable', 'string'], 'kk' => ['nullable', 'string'], @@ -205,16 +205,23 @@ class ProfileController extends Controller $validated['path_ktp'] = $ktpPath; } - $validated['updated_by'] = $user->id(); + $validated['updated_by'] = $user->id; DB::transaction(function () use ($profile, $user, $validated) { $profile->update($validated); - $user->update([ - 'name' => $validated['nama'], + // this user + $profile->user->update([ + 'name' => $validated['nama'], 'email' => $validated['email'], - 'email_verified_at' => $validated['email_verified_at'], - 'updated_by' => $user->id, + 'email_verified_at' => $validated['email_verified_at'] ?? null, + 'updated_by' => auth()->id(), ]); + // $user->update([ + // 'name' => $validated['nama'], + // 'email' => $validated['email'], + // 'email_verified_at' => $validated['email_verified_at'] ?? null, + // 'updated_by' => $user->id, + // ]); }); return response()->json($profile);