feat: API wali murid (Sanctum) + verifikasi admin
- Pasang laravel/sanctum, routes/api.php (prefix api/v1, 10 endpoint) - Migrasi: parent_name di students, parent_students (pivot wali↔anak), parent_devices (token FCM), permission parents-verify - Auth wali: registrasi NISN+HP (auto-verify jika HP cocok data siswa, pending jika tidak) + login token Sanctum - Endpoint: me, logout, students, link anak, violations, sp-letters, notifications, register device - Halaman admin Verifikasi Wali (approve/reject) + menu sidebar - Sync kesiswaan: tarik data orang tua (student_parents) ke students - 8 feature test baru (ParentApiTest) — total suite 39 test hijau
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
/**
|
||||
* Helper normalisasi nomor HP Indonesia.
|
||||
*/
|
||||
class PhoneHelper
|
||||
{
|
||||
/**
|
||||
* Normalisasi: buang semua non-digit, konversi 62 → 0.
|
||||
* Contoh: "+62 812-3456-7890" → "081234567890"
|
||||
*/
|
||||
public static function normalize(?string $phone): string
|
||||
{
|
||||
if ($phone === null) {
|
||||
return '';
|
||||
}
|
||||
$digits = preg_replace('/\D+/', '', (string) $phone);
|
||||
if (str_starts_with($digits, '62')) {
|
||||
$digits = '0' . substr($digits, 2);
|
||||
}
|
||||
return $digits;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apakah dua nomor HP merujuk ke nomor yang sama (toleran terhadap 0/62 & format)?
|
||||
*/
|
||||
public static function matches(?string $a, ?string $b): bool
|
||||
{
|
||||
$na = self::normalize($a);
|
||||
$nb = self::normalize($b);
|
||||
|
||||
if ($na === '' || $nb === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $na === $nb;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user