Php Laravel授权在刀片模板中使用时引发错误

Php Laravel授权在刀片模板中使用时引发错误,php,laravel,Php,Laravel,UrlGenerator正在引发异常 ErrorException in UrlGenerator.php line 337: Action App\Http\Controllers\ProductController@view not defined. 在我的刀片产品视图中有这样的代码 @can('view', App\Product::class) <a href="{{ action('ProductController@show', 1) }}">Product

UrlGenerator正在引发异常

ErrorException in UrlGenerator.php line 337:

Action App\Http\Controllers\ProductController@view not defined. 
在我的刀片产品视图中有这样的代码

@can('view', App\Product::class)
    <a href="{{ action('ProductController@show', 1) }}">Product View</a>
@endcan
我在AuthServiceProvider类中注册了产品策略

protected $policies = [
     Product::class => ProductPolicy::class
];

传递给action方法的第二个参数必须是数组

应该是

  <a href="{{ action('ProductController@show', ['id' => 1]) }}">Product View</a>


请显示您的
ProductController
web.php
我正在使用资源
Route::resource('product','ProductController')
在此api中,第二个参数不需要是数组,因为如果不是数组,则该方法会将其包装在数组中。
  <a href="{{ action('ProductController@show', ['id' => 1]) }}">Product View</a>