我在我的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