[英]Share to view page title
Im getting error: Undefined variable: pageTitle (View: /.../resources/views/layouts/auth.blade.php)
我收到错误:
Undefined variable: pageTitle (View: /.../resources/views/layouts/auth.blade.php)
Line: <title>{{ $pageTitle. ' | '. $settings->company_name }}</title>
行:
<title>{{ $pageTitle. ' | '. $settings->company_name }}</title>
<title>{{ $pageTitle. ' | '. $settings->company_name }}</title>
I'm using fortify auth and I want to share page title to auth blade.我正在使用强化身份验证,我想将页面标题共享给身份验证刀片。
My __construct
code:我的
__construct
代码:
public function __construct()
{
parent::__construct();
\View::share('pageTitle', 'test');
$this->middleware('guest')->except('logout');
}
I've tried also like this:我也试过这样:
public function __construct()
{
parent::__construct();
view()->share('pageTitle', 'test');
$this->middleware('guest')->except('logout');
}
I'm using laravel 8.我正在使用 laravel 8。
The code编码
View::share('key', 'value');
is supposed to be inside a ServiceProvider
's (like app/Providers/AppServiceProvider.php
) boot()
method like in the example , not inside a constructor for what I'm assuming is a Controller
.应该 像示例中那样位于
ServiceProvider
的(例如app/Providers/AppServiceProvider.php
) boot()
方法中,而不是在我假设是Controller
的构造函数中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.