From e0b8910e8d3e43a2222aac700dfe4b31565f6ba1 Mon Sep 17 00:00:00 2001 From: "fauzgabriel@gmail.com" Date: Wed, 22 Apr 2026 13:49:56 +0700 Subject: [PATCH] profile with request id --- app/Http/Controllers/Api/ProfileController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Http/Controllers/Api/ProfileController.php b/app/Http/Controllers/Api/ProfileController.php index 73d8ddb..56cdf69 100644 --- a/app/Http/Controllers/Api/ProfileController.php +++ b/app/Http/Controllers/Api/ProfileController.php @@ -27,6 +27,7 @@ class ProfileController extends Controller $user = Auth::user(); $profile = $user->profile; + $profileId = $user->role === 'petani' ? $profile->id : $request->id; $desaKelurahanId = null; if ($profile->role === 'fasilitator') { @@ -39,6 +40,7 @@ class ProfileController extends Controller $search = strtolower($search); $q->whereRaw('lower(nama) like ?', ["%{$search}%"]); }) + ->when($profileId, fn($q,$v) => $q->where('id',$v)) ->when($desaKelurahanId ?? $request->desa_kelurahan_id, fn($q,$v) => $q->where('desa_kelurahan_id',$v)) ->when($request->kecamatan_id, fn ($q, $v) => $q->whereHas('desaKelurahan', fn ($k) =>