未定义路由[promms2.destroy2]



我不想在我的控制器中制作第二个destroy方法,以删除更大的可删除元素的一部分。我在这条线上看到错误:

`<td><form action="{{ route('proforms2.destroy2',$query2->id) }}" method="POST"></td>`

未定义路由[promms2.destroy2]。

这是路线:

`Route::resource('proforms2', 'ProformController@destroy2');`

这是ProformController.php方法:

public function destroy2(Proform $proform, $query2)
{
$query2->delete();
return redirect()->route('proforms.edit')
->with('success','Product deleted successfully');
}

使用laravelResource时,不需要使用方法调用。你可以做如下操作:

Route::get('delete/proforms/{preform}','ProformController@destroy2')->name('proforms2.destroy2');

并且在控制器方法中,如下

public function destroy2(Proform $proform)
{
$proform->delete();
return redirect()->route('proforms.edit')
->with('success','Product deleted successfully');
}

我可能错过了什么,但你可以做这样的事。

最新更新