我有一个位于 views/layouts/main.blade.php 的主布局。 如何传递 ListingsController.php 中的变量?
public function getMain() {
$uname = Auth::user()->firstname;
$this->layout->content = View::make('listings/main')->with('name', $uname);
}
然后我将其添加到位于列表/主目录中的main.blade.php文件中。
@if(!Auth::check())
<h2>Hello, {{ $name }}</h2>
@endif
它可以工作,但是我无法将该变量传递到views/layouts/main.blade.php中的主布局。我只需要在标题中显示用户的名字。
{
$view->with('name', Auth::user()->firstname);
}); 但我仍然得到相同的错误。 - Halnex