【发布时间】:2020-09-28 17:25:04
【问题描述】:
所以在这里我做了一个 if 以了解或重定向我的表单,但是当我 redirect()->route() 时,我在提交表单时会重新加载页面。 当我直接输入正确的网址时,我只有一个负载可以帮助我吗?
控制器
public function search(Request $request)
{
$search = $request->search;
if($request->search_choise == "num_customer"){
return redirect()->route('show.customer', $search);
}elseif($request->search_choise == "name"){
return redirect()->route('table.customers', $search);
}
}
public function show($id)
{
$customer = User::findOrFail($id);
return view('customers.show', compact('customer'));
}
路线
Route::get('/', ['uses' => 'CustomersController@index', 'as' => 'index.customers']);
Route::post('/', ['uses' => 'CustomersController@search', 'as' => 'search.customers']);
Route::get('/details_client/{id}', ['uses' => 'CustomersController@show', 'as' => 'show.customer']);
张贴我的表格时我的控制台日志
Navigated to http://dev/details_client/6905
Navigated to http://dev/details_client/6905
我的控制台何时去http://dev/details_client/6905
Navigated to http://dev/details_client/6905
更新
我只有在 chrome 上才有!
祝你有美好的一天!
【问题讨论】:
-
检查你的中间件。有时有两次调用 $next($request) 意味着路由被命中两次。
-
您的网页上有广告吗?