我无法弄清楚如何在laravel的刀片模板中显示路径名称。请在下面找到示例代码。谢谢。无法在控制器的刀片模板中显示变量
从控制器(StaffsController.php)
public function index()
{
$thisRoute = Route::current()->uri();
return view('staff.list')>with(compact('thisRoute'));
}
刀片:
{{ $thisRoute }}
这是的var_dump
/home/vagrant/Code/spark/app/Http/Controllers/StaffsController.php:20:string 'staffs' (length=6)
错误:
(1/1) UnexpectedValueException
The Response content must be a string or object implementing __toString(), "boolean" given.
当我在控制器更改代码:
public function index()
{
$thisRoute = Route::current()->uri();
return dd($thisRoute);
}
我得到“员工”为这是正确的输出是从转储一个字符串,右?
你期望打印什么? – Laerte
为什么在'dd'中使用'Route :: current() - > uri()',但是在第一个示例中只是'Route :: current();'? –
也https://laravel.com/docs/5.2/routing#accessing-the-current-route –