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) =>