How do I pass a variable to the layout using Laravel’ Blade templating?

If you’re using @extends in your content layout you can use this:

@extends('master', ['title' => $title])

Note that same as above works with children, like:

@include('views.subView', ['my_variable' => 'my-value'])

Usage

Then where variable is passed to, use it like:

<title>{{ $title ?? 'Default Title' }}</title>

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)