Skip to content

Commit 2306f26

Browse files
committed
fix: district and thana for appointment page
1 parent 63dded1 commit 2306f26

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

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

+14-5
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ public function appointmentPage(Request $request, ?ExpertProfile $expertProfile
5858
$dates[$date->format('l, F d, Y')] = AppointmentTime::where('user_id', $userId)->where('day', $date->format('l'))->first()->times ?? [];
5959
}
6060
$office = !empty($request->query('office_id')) ? Map::find($request->query('office_id')) : null;
61+
$admin = User::role('super admin')->first();
6162
if ($office == null) {
62-
$maps = Map::where(function (Builder $q) use ($request, $expertProfile) {
63+
$maps = Map::where(function (Builder $q) use ($request, $expertProfile, $admin) {
6364
if ($request->query('branch-thana')) {
6465
$q->where('thana', $request->query('branch-thana'));
6566
}
@@ -68,25 +69,33 @@ public function appointmentPage(Request $request, ?ExpertProfile $expertProfile
6869
}
6970
if ($expertProfile != null) {
7071
$q->where('user_id', $expertProfile->user_id);
72+
} else {
73+
$q->where('user_id', $admin->id)->orWhere('user_id', null);
7174
}
7275
})->latest()->get();
7376
} else {
7477
$maps = [ $office ];
7578
}
7679
$branchDistricts = Map::select([ 'district', 'thana', 'user_id' ])
77-
->where(function (Builder $q) use ($request, $expertProfile) {
80+
->where(function (Builder $q) use ($request, $expertProfile, $admin) {
7881
if ($expertProfile != null) {
7982
$q->where('user_id', $expertProfile->user_id);
83+
} else {
84+
$q->where('user_id', $admin->id)->orWhere('user_id', null);
8085
}
8186
})
8287
->distinct()->latest()->get()->pluck('district');
83-
$branchThanas = Map::select([ 'district', 'thana', 'user_id' ])->distinct()->where(function (Builder $q) use ($request, $expertProfile) {
88+
$branchThanas = Map::select([ 'district', 'thana', 'user_id' ])
89+
->distinct()
90+
->where(function (Builder $q) use ($request, $expertProfile, $admin) {
8491
if (!empty($request->query('branch-district'))) {
8592
$q->where('district', $request->query('branch-district'));
8693
}
8794
if ($expertProfile != null) {
8895
$q->where('user_id', $expertProfile->user_id);
89-
}
96+
}else {
97+
$q->where('user_id', $admin->id)->orWhere('user_id', null);
98+
}
9099
})->latest()->get()->pluck('thana');
91100
$banners = getRecords('banners');
92101
$infos1 = Info::where('section_id', 1)->latest()->get();
@@ -103,7 +112,7 @@ public function appointmentVirtual(Request $request, ?ExpertProfile $expertProfi
103112
$date = $carbon->addDay();
104113
$dates[$date->format('l, F d, Y')] = AppointmentTime::where('user_id', $userId)->where('day', $date->format('l'))->first()->times ?? [];
105114
}
106-
115+
107116
$office = !empty($request->query('office_id')) ? Map::find($request->query('office_id')) : null;
108117
$banners = getRecords('banners');
109118
$infos1 = Info::where('section_id', 1)->latest()->get();

resources/views/frontend/pages/appointment/makeAppointment.blade.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
@extends('frontend.layouts.app')
32

43
@section('main')
@@ -162,7 +161,7 @@ class="text-muted fs-6">(selected)</span></h5>
162161
<label for="branch-thana">District <span
163162
class="text-danger">*</span></label>
164163
<select class="tail-select !w-full"
165-
hx-get="{{ route('appointment.make') }}"
164+
hx-get="{{ $expertProfile ?? false ? route('consultation.make', ['expertProfile' => $expertProfile]) : route('appointment.make') }}"
166165
hx-select="#hx-filter-target"
167166
hx-target="#hx-filter-target" hx-swap="outerHTML"
168167
label="Select District" id="branch-district"
@@ -182,7 +181,7 @@ class="text-danger">*</span></label>
182181
<label for="branch-thana">Thana <span
183182
class="text-danger">*</span></label>
184183
<select class="tail-select !w-full"
185-
hx-get={{ route('appointment.make') }}
184+
hx-get="{{ $expertProfile ?? false ? route('consultation.make', ['expertProfile' => $expertProfile]) : route('appointment.make') }}"
186185
hx-select="#hx-filter-target"
187186
hx-target="#hx-filter-target" hx-swap="outerHTML"
188187
id="branch-thana" name="branch-thana" required

0 commit comments

Comments
 (0)