show with profile id
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user