Skip to content

Commit f7964e8

Browse files
committed
fix: office map query
1 parent 404ef07 commit f7964e8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

app/Http/Controllers/Frontend/Page/PageController.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ public function appointmentPage(Request $request, ?ExpertProfile $expertProfile
9393
}
9494
if ($expertProfile != null) {
9595
$q->where('user_id', $expertProfile->user_id);
96-
}else {
97-
$q->where('user_id', $admin->id)->orWhere('user_id', null);
98-
}
96+
} else {
97+
$q->where('user_id', $admin->id)->orWhere('user_id', null);
98+
}
9999
})->latest()->get()->pluck('thana');
100100
$banners = getRecords('banners');
101101
$infos1 = Info::where('section_id', 1)->latest()->get();
@@ -126,19 +126,22 @@ public function aboutPage()
126126
}
127127
public function officePage(Request $request)
128128
{
129-
$maps = Map::where(function (Builder $q) use ($request) {
129+
$admin = User::role('super admin')->first();
130+
$maps = Map::where(function (Builder $q) use ($request, $admin) {
130131
if ($request->query('thana')) {
131132
$q->where('thana', $request->query('thana'));
132133
}
133134
if ($request->query('district')) {
134135
$q->where('district', $request->query('district'));
135136
}
137+
$q->where('user_id', $admin->id)->orWhere('user_id', null);
136138
})->latest()->get();
137139
$districts = Map::select([ 'district', 'thana' ])->distinct()->latest()->get()->pluck('district');
138-
$thanas = Map::select([ 'district', 'thana' ])->distinct()->where(function (Builder $q) use ($request) {
140+
$thanas = Map::select([ 'district', 'thana' ])->distinct()->where(function (Builder $q) use ($request, $admin) {
139141
if (!empty($request->query('district'))) {
140142
$q->where('district', $request->query('district'));
141143
}
144+
$q->where('user_id', $admin->id)->orWhere('user_id', null);
142145
})->latest()->get()->pluck('thana');
143146
return view('frontend.pages.office', compact('maps', 'districts', 'thanas'));
144147
}

0 commit comments

Comments
 (0)