Form:
<form role="form" action='' method='GET'>
<input type="text" placeholder="请输入赛事编码" name="race_num">
<button type="submit">
查询
</button>
</form>
routing:
Route::get('/', function () {
return view('searchscor');
});
Route::get('/','SearchController@searchscor');
Writing like this will only access the second one. How to set routing so that after clicking the submit button (note: form action='' at this time), there is no need to transfer and access the current controller?
1.{{Request::path()}} Get the current route name in the template
2. You can also directly {{url('xxxx')}} on the action side, where xxxx is what you want to process Routing
3. If possible, remember to adopt it
It doesn’t work if the request method and path of your two routes are the same. You can modify one of them.
Then if you want to get the current routing address, you can use the following methods:
Form:
Route:
Route::get('/','SearchController@searchscor');
Controller:
public function searchscor(Request $request){
When action="", it means accessing the current route.