我在我的laravel网站有这个搜索功能,它在我的localhost中工作正常。但是当我使用git hook将它部署到vultr vps时,搜索功能无法正常工作。搜索功能在localhost中正常工作,但在VPS中不能正常工作
当我点击在localhost上的搜索按钮,它会产生这样的网址:http://127.0.0.1:8000/search?query=test&location=&keywords=&_token=I5BDCrqHtdwvsSwrHTrdAAGYfdukPCgU3OAGDySw
但当部署服务器什么也没有发生,它只是做一些回传负荷。
SearchController.php
public function getSearch(Request $request)
{
$this->validate($request, [
'query' => 'required_without_all:keywords,location',
], ['query.required_without_all' => 'Please fill atleast one field.']
);
$query = $request['query'];
$location = $request['location'];
$keywords = $request['keywords'];
if (isset($location) && isset($query) && $keywords) {
$posts = Post::orderBy('created_at', 'desc')->where('title', 'like', '%' . $query . '%')->where('location', 'like', $location)->where('body', 'like', $keywords)->paginate(5);
}
.......
else {
$query = '';
$location = '';
$posts = Post::orderBy('created_at', 'desc')->where('location', 'like', $location)->paginate(5);
}
return view('includes.search-index', ['posts' => $posts]);
}
路由/ web.php
Route::get('/search', [
'uses' => '[email protected]',
'as' => 'search'
]);
search.blade.php
<form action="{{ route('search') }}" method="get" >
.....
</form>
任何想法?看起来请求没有通过?因为我收到了一个空的请求?
'搜索?查询=测试及定位=关键字=&_标记= 4RYLKod1wTRxlblKKpRzKa6Z4YQrAzELjJNP66ti'我尝试调试并返回'query'值,但其原来一个空白页。回报必须是“测试”。 – Joseph