show with profile id

This commit is contained in:
2026-04-22 14:06:18 +07:00
parent e0b8910e8d
commit f0b6049201
@@ -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));
}