我想做的是删除一条记录后,重定向回带有成功消息的特定页面。我得到的错误是重定向导致“ 405方法不允许错误”。如果我删除重定向,则删除工作正常。
我的删除方法
public function destroy($id){
$customer = Customer::find($id);
$customer->delete();
return redirect()->route('customers.index')->with('success','Customer deleted');
}
我尝试过的其他重定向方法
return redirect()->action('CustomerController@index')->with('success','Customer deleted');
redirect('pages.customers.index')->with('success','Customer deleted');
return redirect()->to('/customers')->with('success','Customer deleted')->send();
路由配置
Route::resource('customers','CustomerController');
我的索引方法
public function index()
{
$customers = Customer::all();
return view('pages.customers.index',compact('customers'));
}
根据我在其他帖子上看到的内容,重定向时使用了错误的方法,有没有办法指定要使用的方法?