In Laravel 4, my controller uses a Blade layout:
class PagesController extends BaseController {
protected $layout = \
For future Google'rs that use Laravel 5, you can now also use it with includes,
@include('views.otherView', ['variable' => 1])
In the Blade Template : define a variable like this
@extends('app',['title' => 'Your Title Goes Here'])
@section('content')
And in the app.blade.php or any other of your choice ( I'm just following default Laravel 5 setup )
<title>{{ $title or 'Default title Information if not set explicitly' }}</title>
This is my first answer here. Hope it works.Good luck!
if you want to get the variables of sections you can pay like this:
$_view = new \View;
$_sections = $_view->getFacadeRoot()->getSections();
dd($_sections);
/*
Out:
array:1 [▼
"title" => "Painel"
]
*/
just try this simple method: in controller:-
public function index()
{
$data = array(
'title' => 'Home',
'otherData' => 'Data Here'
);
return view('front.landing')->with($data);
}
And in you layout (app.blade.php) :
<title>{{ $title }} - {{ config('app.name') }} </title>
Thats all.
Simplest way to solve:
view()->share('title', 'My Title Here');
Or using view Facade:
use View;
...
View::share('title', 'My Title Here');
If you're using @extends
in your content layout you can use this:
@extends('master', ['title' => $title])