【发布时间】:2018-03-28 14:14:35
【问题描述】:
当我填写我的搜索并发布它时,它会获取数据并返回它。 在这个查询中,我使用 ->paginate(50);
$products = Product7Days::where('omschrijving', 'LIKE', '%'.$request->omschrijving.'%')
->where('artikelnummer', 'LIKE', '%'.$request->artikelnummer.'%')
->whereIn('relatienummer', $leverancierenArray)
->whereIn('omzetgroep', $omzetgroepenArray)
->whereIn('btwcode', $BTWArray)
->whereBetween('prijs', [$prijsVan, $prijsTot])
->where('totaalaantal', '>=', $aantalVan)
->where('totaalaantal', '<=', $aantalTot)
->paginate(50);
我的路线
Route::get('/artikelen', 'ProductController@index')->name('artikelen');
Route::post('/artikelen', 'ProductController@search')->name('artikelen.search');
所以一切正常,但是当我转到第二页时,由于某种原因没有结果
当我搜索时,它会转到此页面 http://172.16.0.51:8000/artikelen
当我点击第 2 页时,链接是 http://172.16.0.51:8000/artikelen?page=2 但没有数据
刀片文件
@if (isset($products))
<table class="table table-striped table-responsive-xl">
<thead class="thead-dark">
<tr>
<th>Artikelnummer</th>
<th>Omschrijving</th>
<th>Prijs</th>
<th>Totaal <br> verkocht</th>
<th>Totaal <br> omzet</th>
@foreach ($filialen as $filiaal)
@if ($filiaal !== 6)
<th>aantal. <br>F{{$filiaal}}</th>
<th>voorr. <br>F{{$filiaal}}</th>
@else
<th>voorr. <br>F{{$filiaal}}</th>
@endif
@endforeach
</tr>
</thead>
<tbody>
@foreach ($products as $product)
<tr>
<th>{{ $product->artikelnummer}}</th>
<th>{{ $product->omschrijving}}</th>
<th>{{ $product->prijs}}</th>
<th>{{ $product->totaalaantal}}</th>
<th class="text-right">{{ round($product->totaalaantal * $product->prijs, 1) }}</th>
@foreach ($filialen as $filiaal)
@if ($filiaal !== 6)
<th class="text-right">{{ $product["aantalF".$filiaal] }}</th>
<th class="text-right">{{ $product["voorraadF".$filiaal] }}</th>
@else
<th>{{ $product->voorraadF6 }}</th>
@endif
@endforeach
</tr>
@endforeach
</tbody>
</table>
{{ $products->links() }}
@endif
isset() 返回 false...
我很确定当我点击第 2 页时,数据会丢失,但我的问题是如何提供这些数据
【问题讨论】:
-
@WahyuKristianto 没什么可看的,最重要的是你有我要问的所有问题,下面应该是第 2 页的所有数据
-
不使用GET参数是否可以访问
articleen路由?类似?omschrijving=xxx&artikelnummer=xxx
标签: php laravel pagination request