From f0b6049201c82160efbdd19a74e33a1c6fdbc571 Mon Sep 17 00:00:00 2001 From: "fauzgabriel@gmail.com" Date: Wed, 22 Apr 2026 14:06:18 +0700 Subject: [PATCH] show with profile id --- app/Http/Controllers/Api/ProfileController.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/ProfileController.php b/app/Http/Controllers/Api/ProfileController.php index 56cdf69..c02b7a5 100644 --- a/app/Http/Controllers/Api/ProfileController.php +++ b/app/Http/Controllers/Api/ProfileController.php @@ -133,7 +133,13 @@ class ProfileController extends Controller abort(403); } - $profile = Profile::with('desaKelurahan')->where('user_id', Auth::id())->first(); + $user = Auth::user(); + $profile = $user->profile; + $profileId = $user->role === 'petani' ? $profile->id : $id; + + $profile = Profile::with('desaKelurahan') + ->when($profileId, fn($q,$v) => $q->where('id',$v)) + ->where('user_id', Auth::id())->first(); return response()->json(new ProfileResource($profile)); }