@@ -59,18 +59,21 @@ public function appointmentPage(Request $request, ?ExpertProfile $expertProfile
59
59
}
60
60
$ office = !empty ($ request ->query ('office_id ' )) ? Map::find ($ request ->query ('office_id ' )) : null ;
61
61
$ admin = User::role ('super admin ' )->first ();
62
+ $ defaultDistrict = $ expertProfile != null ? $ request ->query ('branch-district ' , 'Chattogram ' ) : null ;
62
63
if ($ office == null ) {
63
- $ maps = Map::where (function (Builder $ q ) use ($ request , $ expertProfile , $ admin ) {
64
+ $ maps = Map::where (function (Builder $ q ) use ($ request , $ expertProfile , $ admin, $ defaultDistrict ) {
64
65
if ($ request ->query ('branch-thana ' )) {
65
66
$ q ->where ('thana ' , $ request ->query ('branch-thana ' ));
66
67
}
67
- if ($ request -> query ( ' branch-district ' ) ) {
68
- $ q ->where ('district ' , $ request -> query ( ' branch-district ' ) );
68
+ if ($ defaultDistrict ) {
69
+ $ q ->where ('district ' , $ defaultDistrict );
69
70
}
70
71
if ($ expertProfile != null ) {
71
72
$ q ->where ('user_id ' , $ expertProfile ->user_id );
72
73
} else {
73
- $ q ->where ('user_id ' , $ admin ->id )->orWhere ('user_id ' , null );
74
+ $ q ->where (function (Builder $ builder ) use ($ admin ) {
75
+ $ builder ->where ('user_id ' , $ admin ->id )->orWhere ('user_id ' , null );
76
+ });
74
77
}
75
78
})->latest ()->get ();
76
79
} else {
@@ -81,20 +84,24 @@ public function appointmentPage(Request $request, ?ExpertProfile $expertProfile
81
84
if ($ expertProfile != null ) {
82
85
$ q ->where ('user_id ' , $ expertProfile ->user_id );
83
86
} else {
84
- $ q ->where ('user_id ' , $ admin ->id )->orWhere ('user_id ' , null );
87
+ $ q ->where (function (Builder $ builder ) use ($ admin ) {
88
+ $ builder ->where ('user_id ' , $ admin ->id )->orWhere ('user_id ' , null );
89
+ });
85
90
}
86
91
})
87
92
->distinct ()->latest ()->get ()->pluck ('district ' );
88
93
$ branchThanas = Map::select ([ 'district ' , 'thana ' , 'user_id ' ])
89
94
->distinct ()
90
- ->where (function (Builder $ q ) use ($ request , $ expertProfile , $ admin ) {
91
- if (! empty ( $ request -> query ( ' branch-district ' )) ) {
92
- $ q ->where ('district ' , $ request -> query ( ' branch-district ' ) );
95
+ ->where (function (Builder $ q ) use ($ request , $ expertProfile , $ admin, $ defaultDistrict ) {
96
+ if ($ defaultDistrict ) {
97
+ $ q ->where ('district ' , $ defaultDistrict );
93
98
}
94
99
if ($ expertProfile != null ) {
95
100
$ q ->where ('user_id ' , $ expertProfile ->user_id );
96
101
} else {
97
- $ q ->where ('user_id ' , $ admin ->id )->orWhere ('user_id ' , null );
102
+ $ q ->where (function (Builder $ builder ) use ($ admin ) {
103
+ $ builder ->where ('user_id ' , $ admin ->id )->orWhere ('user_id ' , null );
104
+ });
98
105
}
99
106
})->latest ()->get ()->pluck ('thana ' );
100
107
$ banners = getRecords ('banners ' );
@@ -128,20 +135,30 @@ public function officePage(Request $request)
128
135
{
129
136
$ admin = User::role ('super admin ' )->first ();
130
137
$ maps = Map::where (function (Builder $ q ) use ($ request , $ admin ) {
131
- if ($ request ->query ('thana ' )) {
132
- $ q ->where ('thana ' , $ request ->query ('thana ' ));
138
+ if ($ request ->query ('thana ' , ' Karnaphuli ' )) {
139
+ $ q ->where ('thana ' , $ request ->query ('thana ' , ' Karnaphuli ' ));
133
140
}
134
- if ($ request ->query ('district ' )) {
135
- $ q ->where ('district ' , $ request ->query ('district ' ));
141
+ if ($ request ->query ('district ' , ' Chattogram ' )) {
142
+ $ q ->where ('district ' , $ request ->query ('district ' , ' Chattogram ' ));
136
143
}
137
- $ q ->where ('user_id ' , $ admin ->id )->orWhere ('user_id ' , null );
144
+ $ q ->where (function (Builder $ builder ) use ($ admin ) {
145
+ $ builder ->where ('user_id ' , $ admin ->id )->orWhere ('user_id ' , null );
146
+ });
138
147
})->latest ()->get ();
139
- $ districts = Map::select ([ 'district ' , 'thana ' ])->distinct ()->latest ()->get ()->pluck ('district ' );
148
+ $ districts = Map::select ([ 'district ' , 'thana ' ])->distinct ()
149
+ ->where (function (Builder $ q ) use ($ admin ) {
150
+ $ q ->where (function (Builder $ builder ) use ($ admin ) {
151
+ $ builder ->where ('user_id ' , $ admin ->id )->orWhere ('user_id ' , null );
152
+ });
153
+
154
+ })->latest ()->get ()->pluck ('district ' );
140
155
$ thanas = Map::select ([ 'district ' , 'thana ' ])->distinct ()->where (function (Builder $ q ) use ($ request , $ admin ) {
141
156
if (!empty ($ request ->query ('district ' ))) {
142
157
$ q ->where ('district ' , $ request ->query ('district ' ));
143
158
}
144
- $ q ->where ('user_id ' , $ admin ->id )->orWhere ('user_id ' , null );
159
+ $ q ->where (function (Builder $ builder ) use ($ admin ) {
160
+ $ builder ->where ('user_id ' , $ admin ->id )->orWhere ('user_id ' , null );
161
+ });
145
162
})->latest ()->get ()->pluck ('thana ' );
146
163
return view ('frontend.pages.office ' , compact ('maps ' , 'districts ' , 'thanas ' ));
147
164
}
0 commit comments