您好我关注如何设置搜索表单的教程,但我收到route
错误(NotFoundHttpException
)。
形式
{!! Form::open(['method'=>'GET' ,'url' => 'search', 'class'=>'form-group main-form', 'id'=>'search-form', 'role'=>'form']) !!}
{{ csrf_field() }}
<div style="display:none"><input name="utf8" type="hidden" value="✓"></div>
<input class="form-group main-form" id="q_objname_en_cont" name="searchKey" placeholder='Search by Job title' required="required" style="height:40px;width:60%" type="search">
<input class="btn btn-warning" type="submit" value="Search">
{!! Form::close() !!}
路线
//Search route(get)
Route::get('search/{searchkey}', 'EmploiController@search')->where('searchkey', '[A-Za-z]+')->name('search');
url(浏览器)
http://localhost:8000/search?_token=LJpgN3AwCFoDElOkFsSOX8BBLU1IFOzMvUYiokQj&utf8=%E2%9C%93&searchKey=quia
答案 0 :(得分:2)
将路线更改为此。当您将搜索参数作为查询字符串传递时,您不需要url的第二部分。
var img = document.getElementById("b3");
将表单更改为此。在使用表单GET方法时,您不需要发送csrf标记。
Traceback (most recent call last):
File "/Users/***/PycharmProjects/Bluey/main.py", line 1, in <module>
import bluetooth
File "build/bdist.macosx-10.10-intel/egg/bluetooth/__init__.py", line 47, in <module>
File "build/bdist.macosx-10.10-intel/egg/bluetooth/osx.py", line 1, in <module>
File "build/bdist.macosx-10.10-intel/egg/lightblue/__init__.py", line 160, in <module>
File "build/bdist.macosx-10.10-intel/egg/lightblue/_lightblue.py", line 31, in <module>
File "build/bdist.macosx-10.10-intel/egg/lightblue/_macutil.py", line 169, in <module>
objc.BadPrototypeError: Objective-C expects 1 arguments, Python argument has 2 arguments for <unbound selector sleep of BBCocoaSleeper at 0x103cdc030>
Process finished with exit code 1
我还删除了不需要的输入Route::get('search', 'EmploiController@search')->name('search');
。如果有意的话,请加回来。
答案 1 :(得分:0)
我认为您所关注的教程一切都有问题,没有安全问题,当然,这不是在Laravel中实现搜索的正确方法,您将csrf_token暴露给每个人的世界请求到该路线。
我的建议是阅读更好的资源,深入了解文档。
https://laracasts.com/discuss/channels/laravel/search-option-in-laravel-5?page=1