I know it's probably super simple, but I just started using laravel today, I've always been on codeigniter before. The problem I have is that laravel tells me that my variable is not defined ...
Controller:
public function index()
{
$data['pageTitle']='Connexion';
return view('login')->with($data);
}
The line concerned in login.blade.php:
@extends('layout.header', $pageTitle)
Error:
"Undefined variable: pageTitle (View: G:\Winginx\home\laravel\public_html\resources\views\login.blade.php)"
Thanks !
You're getting this error because you're trying to use $pageTitle
variable but you do not pass it to the view.
So, to fix this you can change this line in the view:
@extends('layout.header', $data['pageTitle'])
Or you can change method in controller to:
public function index()
{
return view('login', ['pageTitle' => 'Connexion']);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.