我需要有自己的自定義設計,我可以在其中添加 @foreach 并自定義設計,我不知道該怎么做,我嘗試了很多方法但失敗了。有人可以建議我一個解決方案,或者建議我遵循任何教程,我可以根據需要將過濾后的數據加載到我的視圖中。這是我的stores.blade.php搜索字段和表格所在的位置,? ?<h3 align="center">Store Locator</h3>? ? ? ? <div class="row">? ? ? ? ? ? <div class="col-md-4"></div>? ? ? ? ? ? <div class="col-md-4">? ? ? ? ? ? ? ? <div class="form-group">? ? ? ? ? ? ? ? ? ? <select name="filter_district" id="filter_district" class="form-control" required>? ? ? ? ? ? ? ? ? ? ? ? <option value="">Select Distric</option>? ? ? ? ? ? ? ? ? ? ? ? @foreach ($district_name as $district)? ? ? ? ? ? ? ? ? ? ? ? ? ? ?<option value="{{ $district->district }}">{{ $district->district }}</option>? ? ? ? ? ? ? ? ? ? ? ? @endforeach? ? ? ? ? ? ? ? ? ? </select>? ? ? ? ? ? ? ? </div>? ? ? ? ? ? ? ? <div class="form-group">? ? ? ? ? ? ? ? ? ? <select name="filter_outlet" id="filter_outlet" class="form-control" required>? ? ? ? ? ? ? ? ? ? ? ?<option value="">Select Outlet</option>? ? ? ? ? ? ? ? ? ? ? ? @foreach($outlet_name as $country)? ? ? ? ? ? ? ? ? ? ? ? ? ? <option value="{{ $country->outlet }}">{{ $country->outlet }}</option>? ? ? ? ? ? ? ? ? ? ? ? @endforeach? ? ? ? ? ? ? ? ? ? </select>? ? ? ? ? ? ? ? </div>? ? ? ? ? ? ? ??? ? ? ? ? ? ? ? <div class="form-group" align="center">? ? ? ? ? ? ? ? ? ? <button type="button" name="filter" id="filter" class="btn form-submit">Filter</button>? ? ? ? ? ? ? ? ? ? <button type="button" name="reset" id="reset" class="btn form-submit">Reset</button>? ? ? ? ? ? ? ? </div>? ? ? ? ? ? </div>? ? ? ? ? ? <div class="col-md-4"></div>? ? ? ? </div>? ? ? ? <br />
1 回答

FFIVE
TA貢獻1797條經驗 獲得超6個贊
通過 eager load 發送結果時,需要包含商店的區域名稱。因此,在您的商店模型中,創建一個belongsTo關系
public function district() {
return $this->belongsTo('App\District', 'district');
}
所以當你發送結果時,你可以寫
$data = Store::select('id','outlet', 'province', 'district', 'no1', 'no2', 'no3', 'address')
->where('district', $request->filter_district)
->where('outlet', $request->filter_outlet)
->with(['district'])
->get();
- 1 回答
- 0 關注
- 144 瀏覽
添加回答
舉報
0/150
提交
取消