Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Blade How to print out uri with @show action

In my view, I want to print a controller uri like this ShopController@show.

set the var $controller = 'ShopControll';

in the view:

action($controller.'@show',$id)

but there are some error occured:

ErrorException in UrlGenerator.php line 603:
Action App\Http\Controllers\ShopController<?php echo $__env->yieldSection(); ?> not defined. 

if like this:

action('ShopController@show',$id)

it works, output is:

http://example.com/show/1

So, what's the difference?

like image 488
liuran Avatar asked Dec 31 '25 09:12

liuran


1 Answers

@show is a blade directive, blade parse it you want to show this as section please check here example

@section('sidebar')
            This is the master sidebar.
@show

https://laravel.com/docs/5.2/blade#template-inheritance

you can modify you method like this

action($controller,'show',$id)
like image 198
umefarooq Avatar answered Jan 02 '26 00:01

umefarooq