fix: simpan nomor HP wali saat registrasi & taut anak → kolom HP terisi, backfill data siswa saat approve jalan, auto-verifikasi kini benar-benar berfungsi (diuji end-to-end +62 vs 0)
This commit is contained in:
@@ -43,10 +43,11 @@ class ParentVerificationController extends Controller
|
||||
]);
|
||||
|
||||
// Isi data kontak wali ke siswa bila masih kosong
|
||||
if ($link->student && empty($link->student->parent_phone)) {
|
||||
// (user->phone kini terisi sejak registrasi — register & link-child menyimpannya)
|
||||
if ($link->student && empty($link->student->parent_phone) && ! empty($link->user->phone)) {
|
||||
$link->student->update([
|
||||
'parent_name' => $link->user->name,
|
||||
'parent_phone' => $link->user->phone ?: ($link->student->parent_phone),
|
||||
'parent_phone' => $link->user->phone,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -77,9 +77,16 @@ class ParentAuthController extends Controller
|
||||
'role' => 'parent',
|
||||
'roles' => ['parent'],
|
||||
'is_active' => true,
|
||||
'phone' => $phone,
|
||||
]);
|
||||
}
|
||||
|
||||
// Simpan nomor HP wali ke akun bila masih kosong (dipakai juga
|
||||
// untuk mengisi data kontak siswa saat verifikasi oleh admin).
|
||||
if (empty($user->phone)) {
|
||||
$user->update(['phone' => $phone]);
|
||||
}
|
||||
|
||||
// Verifikasi otomatis jika HP cocok dengan data orang tua di database
|
||||
$autoVerified = PhoneHelper::matches($phone, $student->parent_phone);
|
||||
|
||||
|
||||
@@ -531,6 +531,11 @@ class ParentStudentController extends Controller
|
||||
|
||||
$autoVerified = PhoneHelper::matches(trim($validated['parent_phone']), $student->parent_phone);
|
||||
|
||||
// Simpan nomor HP wali bila akun belum punya.
|
||||
if (empty($user->phone)) {
|
||||
$user->update(['phone' => trim($validated['parent_phone'])]);
|
||||
}
|
||||
|
||||
$link = ParentStudent::create([
|
||||
'user_id' => $user->id,
|
||||
'student_id' => $student->id,
|
||||
|
||||
Reference in New Issue
Block a user