Php Laravel Blade如何使用@show action打印uri
在我看来,我想像这样打印控制器uriPhp Laravel Blade如何使用@show action打印uri,php,laravel,laravel-blade,Php,Laravel,Laravel Blade,在我看来,我想像这样打印控制器uriShopController@show 设置var$controller='ShopControll' 在视图中: action($controller.'@show',$id) ErrorException in UrlGenerator.php line 603: Action App\Http\Controllers\ShopController<?php echo $__env->yieldSection(); ?> not def
ShopController@show
设置var$controller='ShopControll'代码>
在视图中:
action($controller.'@show',$id)
ErrorException in UrlGenerator.php line 603:
Action App\Http\Controllers\ShopController<?php echo $__env->yieldSection(); ?> not defined.
action('ShopController@show',$id)
http://example.com/show/1
但出现了一些错误:
action($controller.'@show',$id)
ErrorException in UrlGenerator.php line 603:
Action App\Http\Controllers\ShopController<?php echo $__env->yieldSection(); ?> not defined.
action('ShopController@show',$id)
http://example.com/show/1
工作正常,输出为:
action($controller.'@show',$id)
ErrorException in UrlGenerator.php line 603:
Action App\Http\Controllers\ShopController<?php echo $__env->yieldSection(); ?> not defined.
action('ShopController@show',$id)
http://example.com/show/1
那么,有什么区别呢?@show是一个blade指令,blade解析它。如果要将其显示为一节,请检查这里的示例
@section('sidebar')
This is the master sidebar.
@show
您可以像这样修改您的方法
action($controller,'show',$id)
对于Laravel>=5.3,您可以使用以下组合:
对于早期版本,我认为(仅在5.3上再次测试),这也应该适用:
{{ @action($controller.'@show', ['id' => $id])}}