我一直在努力得到这个,但我做不到。搜索一切正常,分页也出现了,但是每当我点击任何页码时都会打开一个空白页面,因为没有“获取”该请求的路线,任何人都可以引导到某个地方,我可以找到如何显示其他带有搜索查询的页面还是我必须创建获取路线才能显示其他页面?我都迷茫了怎么办?
尝试使用 GET 方法仍然无法正常工作
路线
Route::get('search/','Coins@search')->name('coin.search');
控制器
public function search(){
$keyword = Input::get('search');
if($keyword){
$result = [];
$resultByName = Coin::
where('type','=','coin')
->where('parent_id','=',0)
->where('coin_name','LIKE',"%{$keyword}%")
->orderBy('id', 'asc')
->paginate(10);
$resultByDescription = Coin::where('type','=','coin')
->where('parent_id','=',0)
->where('description','LIKE',"%{$keyword}%")
->orderBy('id', 'asc')
->paginate(10);
if($resultByName->count()) {
$result = $resultByName;
$message = "Coin Detail found in coin name !! based on searching data : ".$keyword;
}else{
if($resultByDescription->count()){
$result = $resultByDescription;
$message = "Coin Detail found in description !! based on searching data : ".$keyword;
}else{
$result = Coin::where('type','=','coin')->where('parent_id','=',0)->get();
$message = "No Coin Found !! based on searching data : ".$keyword;
}
}
return view($this->layout.'coins')->with([
'allCoins' => $result,
'message' => $message
]);
}
}
刀
{!! Form::open([
'route' => 'coin.search'
,'method' => 'GET'
,'id' => 'coinSearch'])
!!}
<input type="text" placeholder="Search Your Coin Here . . . " name="search">
<button type="submit" class="btn btn-sm btn-primary">Search</button>
{!! Form::close() !!}
{!! $allCoins->render() !!}