我正在尝试在Laravel 5中实现搜索功能,但我的查询没有得到任何结果。 我一直收到这个错误
“抱歉,找不到您要查找的页面。”
这是search()
frequencesController
函数
public function search(){
$results = frequences::where(function($q) use ($request) {
$q->orWhere('time_db', 'like', 'time');
})->get();
}
这是路线:
Route::post('search', ['as' => 'search', 'frequences' => 'frequencesController@search']);
和页面:
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>search</title>
</head>
<body>
<form action="App\Http\Controllers\frequencesController@search" method="post">
<p>time</p>
<input type="time" name="search " value="time"/>
<input type="submit" value="search">
</form>
</body>
</html>
有什么问题?请
答案 0 :(得分:0)
试试这个
public function search(Request $request){
$search=$request->get('search')
$results = frequences::where(function($q) use ($search) {
$q->orWhere('time_db', 'like', '%' . $search . '%');
})->get();
}
表格
<form action="{{url('/search')}}" method="post">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<p>time</p>
<input type="time" name="search" value="time">
<input type="submit" value="search">
</form>