控制器:
public function search(Request $request)
{
$stores = Store::with('router', 'tills', 'backOffices','contacts', 'storeStatus', 'storeStatus', 'storeType', 'scos', 'fuelBrand')->where('store_name', 'like', '%' . $request['find'] . '%')->paginate(13);
return view('store.index')->with([
'stores' => $stores,
'find' => $request['find'],
]);
}视图
<div class="flex-1 mx-10">
<form action="/store/search" method="POST" name="search" role="search">
@csrf
<input id="index-view-search" name="find" type="text" placeholder="Search"
class="border rounded w-full p-1"
>
</form>
</div>
<div class="mx-3">
@if ( Route::is('store.index') )
{{ $stores->links() }}
@else
{!! $stores->appends(['find' => $find])->links() !!}
@endif
</div>路由
Route::any('/store/search', "StoreController@search")->name('stores.search');有人能告诉我为什么当我点击这段代码的分页链接时会得到404吗?
路由接受post或get,我传回搜索词和页码.../store/search?find=evans&page=2是分页实例所请求的,我看不出出了什么问题
发布于 2020-07-15 15:54:38
我实际上弄清楚了,因为我有一个资源控制器,所以store/{id}是活动的,所以我需要重命名URI。
https://stackoverflow.com/questions/62909903
复制相似问题