From 25502b99f32b8eebc6e79ad1c46ada9a3fabee20 Mon Sep 17 00:00:00 2001 From: Novy San87 Date: Thu, 6 Aug 2026 21:52:07 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20Data=20Wali=20Murid=20diperkaya=20?= =?UTF-8?q?=E2=80=94=20relasi=20(Ayah/Ibu/Wali),=20email,=20status=20akun,?= =?UTF-8?q?=20perangkat=20&=20last=20active=20(fix=20$pending/$baruMingguI?= =?UTF-8?q?ni)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Admin/WaliMuridController.php | 11 +++- app/Models/User.php | 9 +++ resources/views/parents/index.blade.php | 62 +++++++++++++++++-- 3 files changed, 73 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/Admin/WaliMuridController.php b/app/Http/Controllers/Admin/WaliMuridController.php index 6926782..9943783 100644 --- a/app/Http/Controllers/Admin/WaliMuridController.php +++ b/app/Http/Controllers/Admin/WaliMuridController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; +use App\Models\ParentStudent; use App\Models\User; use Illuminate\Http\Request; use Illuminate\View\View; @@ -16,14 +17,18 @@ class WaliMuridController extends Controller { $query = User::query() ->where('role', 'parent') - ->with(['parentStudents' => fn ($q) => $q->with('student:id,nisn,full_name,class_name')]); + ->with([ + 'parentStudents' => fn ($q) => $q->with('student:id,nisn,full_name,class_name'), + 'parentDevices', + ]); if ($request->filled('search')) { $search = $request->search; $query->where(function ($q) use ($search) { $q->where('name', 'like', "%{$search}%") ->orWhere('username', 'like', "%{$search}%") - ->orWhere('phone', 'like', "%{$search}%"); + ->orWhere('phone', 'like', "%{$search}%") + ->orWhere('email', 'like', "%{$search}%"); }); } @@ -33,7 +38,7 @@ class WaliMuridController extends Controller $totalAktif = User::where('role', 'parent') ->whereHas('parentStudents', fn ($q) => $q->where('status', 'active')) ->count(); - $pending = \App\Models\ParentStudent::where('status', 'pending')->count(); + $pending = ParentStudent::where('status', 'pending')->count(); $baruMingguIni = User::where('role', 'parent') ->where('created_at', '>=', now()->subDays(7)) ->count(); diff --git a/app/Models/User.php b/app/Models/User.php index 30ffa58..29933dc 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -146,6 +146,15 @@ class User extends Authenticatable return $this->hasMany(\App\Models\ParentStudent::class, 'user_id'); } + /** + * Perangkat (HP/browser) yang pernah dipakai wali untuk FCM push. + */ + public function parentDevices() + { + return $this->hasMany(\App\Models\ParentDevice::class, 'user_id') + ->orderByDesc('last_active_at'); + } + /** * Anak-anak (siswa) milik akun wali, hanya yang statusnya aktif. */ diff --git a/resources/views/parents/index.blade.php b/resources/views/parents/index.blade.php index c3f4ecc..700d74e 100644 --- a/resources/views/parents/index.blade.php +++ b/resources/views/parents/index.blade.php @@ -138,8 +138,9 @@ Wali - Nomor HP + Kontak Putra/Putri Tertaut + Perangkat Terdaftar Aksi @@ -155,16 +156,36 @@
-

{{ $user->name }}

+

+ {{ $user->name }} + @php $relations = collect($user->parentStudents)->pluck('relation')->filter(); @endphp + @if($relations->contains('father')) + AYAH + @elseif($relations->contains('mother')) + IBU + @elseif($relations->contains('guardian')) + WALI + @endif +

{{ $user->username }}

+ + + {{ $user->is_active ? 'Akun aktif' : 'Akun nonaktif' }} +
- - - {{ $user->phone ?? '-' }} - +
+ + + {{ $user->phone ?? '-' }} + + + + {{ $user->email ?? 'tanpa email' }} + +
@if($user->parentStudents->isEmpty()) @@ -197,6 +218,35 @@ @endif + + @if($user->parentDevices->isEmpty()) + Belum ada perangkat + @else +
+ @foreach($user->parentDevices as $device) + + @if($device->platform === 'android') + + + + @elseif($device->platform === 'ios') + + + + @else + + + + @endif +
+

{{ $device->device_name }}

+

aktif {{ $device->last_active_at?->diffForHumans() }}

+
+
+ @endforeach +
+ @endif +