profile with request id
This commit is contained in:
@@ -27,6 +27,7 @@ class ProfileController extends Controller
|
|||||||
|
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
$profile = $user->profile;
|
$profile = $user->profile;
|
||||||
|
$profileId = $user->role === 'petani' ? $profile->id : $request->id;
|
||||||
|
|
||||||
$desaKelurahanId = null;
|
$desaKelurahanId = null;
|
||||||
if ($profile->role === 'fasilitator') {
|
if ($profile->role === 'fasilitator') {
|
||||||
@@ -39,6 +40,7 @@ class ProfileController extends Controller
|
|||||||
$search = strtolower($search);
|
$search = strtolower($search);
|
||||||
$q->whereRaw('lower(nama) like ?', ["%{$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($desaKelurahanId ?? $request->desa_kelurahan_id, fn($q,$v) => $q->where('desa_kelurahan_id',$v))
|
||||||
->when($request->kecamatan_id, fn ($q, $v) =>
|
->when($request->kecamatan_id, fn ($q, $v) =>
|
||||||
$q->whereHas('desaKelurahan', fn ($k) =>
|
$q->whereHas('desaKelurahan', fn ($k) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user