I'm having problem display search result by useing multiple dropdown boxes.
my Laravel Framework is 6.18.8
This is table stracture.
id | name | type | wc | fc | yc | sc |
User choose value of each select box and important thing is User MUST select 'WC' column value.
For example. A user choose below
- 'type' as w value
- 'wc' as N1 value (USER must select this column)
- 'fc' as f02 value
- 'yc' as yc1 value
- 'sc' as Z03 value
I would like to fetch above matched result. Could you please teach me how to write correct search function please?
Here is search page. search.blade.php
<form action="" class="form-image-upload" method="POST" enctype="multipart/form-data">
<div class="col-md-5">
<strong>TYPE</strong>
<select name="type" class="form-control">
<option value="-" selected>-</option>
<option value="j">j</option>
<option value="w">w</option>
</select>
</div>
<div class="col-md-5">
<strong>wc</strong>
<select name="wc" class="form-control">
<option value="N0" selected>0</option>
<option value="N1">1</option>
<option value="N2">2</option>
<option value="N3">3</option>
</select>
</div>
<div class="col-md-5">
<strong>FC</strong>
<select name="fc" class="form-control">
<option value="0" selected>0</option>
<option value="f01">f01</option>
<option value="f02">f02</option>
<option value="f03">f03</option>
</select>
</div>
<div class="col-md-5">
<strong>YC</strong>
<select name="yc" class="form-control">
<option value="0" selected>0</option>
<option value="yc1">yc1</option>
<option value="yc2">yc2</option>
</select>
</div>
<div class="col-md-5">
<strong>SC</strong>
<select name="sc" class="form-control">
<option value="Z01" selected>Z01</option>
<option value="Z02" selected>Z02</option>
<option value="Z03" selected>Z03</option>
</select>
</div>
<div class="col-md-2">
<br/>
<button type="submit" class="btn btn-success">Search</button>
</div>
</div>
</form>
Controller
public function order(Request $request)
{
$this->validate($request, [
'wc' => 'required'
]);
$images = ImageGallery::where('type', 'like', '%')
->where('wc', 'like', '%')
->where('fc', 'like', '%')
->where('yc', 'like', '%')
->where('sc', 'like', '%')
$result = compact('images');
return view('result',compact('result'));
}
WEB.php
// search section
Route::post('search', 'ImageGalleryController@order');
Route::get('search', 'ImageGalleryController@search');
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire