路线 [proforms2.destroy2] 未定义

Route [proforms2.destroy2] not defined

我不想在我的控制器中使用第二个 destroy 方法来删​​除较大的可删除元素的一部分。我在这条线上看到了错误:

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

路线 [proforms2.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');
}

您在使用 laravel Resource 时不需要使用方法调用。您可以执行以下操作:

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');
}

我可能错过了一些东西,但你可以做类似的事情。