【发布时间】:2016-10-14 21:20:27
【问题描述】:
我正在尝试在 laravel 5.1 中创建一个作曲家视图
这是我的 AppServiceProvider:
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
view()->composer('layouts.dashboard', function ($view) {
dd($view);
}
);
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}
它给了我:
View {#486 ▼
#factory: Factory {#107 ▶}
#engine: CompilerEngine {#382 ▶}
#view: "layouts.dashboard"
#data: array:9 [▼
"obLevel" => 0
"__env" => Factory {#107 ▶}
"app" => Application {#2 ▶}
"errors" => ViewErrorBag {#322 ▶}
"currentModelName" => "Torneo"
"modelPlural" => "Torneos"
"levels" => Collection {#383 ▶}
"categories" => Collection {#390 ▶}
"tournament" => Tournament {#379 ▶}
]
#path: " /Users/Julien/laravel/resources/views/layouts/dashboard.blade.php"
}
现在,我需要访问 currentModelName。
我尝试了$view->data 或$view->data->currentModelName,但它返回null
有什么想法吗?
【问题讨论】:
标签: php laravel nginx laravel-5.1