Skip to content

Commit 6f0317e

Browse files
committed
filter thana and branch in expert browser
1 parent b66bfbc commit 6f0317e

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

app/Http/Controllers/ExpertController.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function browse(Request $request) {
4040
$posts = $request->query('posts');
4141
$district = $request->query('district');
4242
$thana = $request->query('thana');
43+
$dist_only = $request->query('dist_only') == 'false';
4344
$expTo = $request->query('experience_to');
4445
$expFrom = $request->query('experience_from');
4546
if ($posts) {
@@ -48,7 +49,7 @@ public function browse(Request $request) {
4849
if ($district) {
4950
$q->where('district', $district);
5051
}
51-
if ($thana) {
52+
if ($thana && $dist_only) {
5253
$q->where('thana', $thana);
5354
}
5455
if ($expTo) {

resources/views/components/backend/form/select-input.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</label>
1616
@endif
1717
<select {{ $attributes->merge(['class' => 'form-select text-capitalize px-3 py-2'])->merge() }}>
18-
<option disabled selected>{{ $placeholder }}</option>
18+
<option disabled selected value="">{{ $placeholder }}</option>
1919
{{ $slot }}
2020
</select>
2121
@error($name)

resources/views/frontend/pages/expert/browse.blade.php

+21-9
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ class="btn btn-secondary text-dark rounded-1 d-lg-none mb-3 fw-medium waves-effe
2727
</button>
2828
</div>
2929
<div id="filter-menu" class="col-6 col-sm-6 col-md-4 col-lg-3 d-none d-lg-block">
30-
<form hx-get="{{ route('expert.browse') }}" hx-target="#hx-filtered-experts" hx-swap="outerHTML"
31-
hx-select="#hx-filtered-experts" hx-push-url="true" method="get">
30+
<form hx-get="{{ route('expert.browse') }}" hx-trigger="change from:.hx-input"
31+
hx-target="#hx-filtered-experts" hx-swap="outerHTML" hx-select="#hx-filtered-experts"
32+
hx-push-url="true" method="get">
3233
<div class="filter-menu p-3 shadow bg-light rounded-2 ">
3334
<div class="filters">
3435
<x-range-slider class="" tooltips="false" name="experience" id="experience"
@@ -42,26 +43,27 @@ class="btn btn-secondary text-dark rounded-1 d-lg-none mb-3 fw-medium waves-effe
4243
<span class="mdi mdi-chevron-down"></span>
4344
</div>
4445
</div>
45-
<div class="card-body">
46+
<div class="card-body" hx-target="hx-form-body">
4647
@php
4748
$selectedDistrict = request()->query('district');
4849
$selectedThana = request()->query('thana');
4950
$selectedBranch = request()->query('branch');
5051
@endphp
51-
<x-form.selectize class="mb-2" id="district" name="district" label="District"
52-
placeholder="District">
52+
<x-backend.form.select-input class="mb-2 hx-input" id="district" name="district"
53+
label="District" placeholder="District">
5354
@foreach ($districts as $district)
5455
<option value="{{ $district }}" @selected($district === $selectedDistrict)>
5556
{{ $district }}</option>
5657
@endforeach
57-
</x-form.selectize>
58-
<x-form.selectize class="mb-2" id="thana" name="thana" label="Thana"
59-
placeholder="Thana">
58+
</x-backend.form.select-input>
59+
<input id="dist_only" name="dist_only" value="true" class="d-none" />
60+
<x-backend.form.select-input class="mb-2 hx-input" id="thana" name="thana"
61+
label="Thana" placeholder="Thana">
6062
@foreach ($thanas as $thana)
6163
<option value="{{ $thana }}" @selected($thana === $selectedThana)>
6264
{{ $thana }}</option>
6365
@endforeach
64-
</x-form.selectize>
66+
</x-backend.form.select-input>
6567
</div>
6668
</div>
6769
<div class="card">
@@ -200,6 +202,16 @@ class="btn btn-outline-primary fw-medium w-100 mb-2">Profile</a>
200202

201203
@push('customJs')
202204
<script>
205+
document.querySelectorAll('.hx-input').forEach(input => {
206+
input.addEventListener('input', (e) => {
207+
let thana = $("[name='thana']")
208+
let district = $("[name='district']")
209+
if (e.target.id == 'thana') {
210+
let dist_only = $("[name='dist_only']")
211+
dist_only.val('false')
212+
}
213+
});
214+
});
203215
const filter = {
204216
toggle: {
205217
btnIcon: function(jQBtn) {

0 commit comments

Comments
 (0)