Support the ongoing development of Laravel.io →
posted 9 years ago
Blade

I want to know if it is possible to pass data from a controller, to a view that extends a master, to the master layout, without using yield/section.

example:
I have a master layout blade, that includes some common meta in the head (opengraph, schema markup) that i want to fill from a Model.
I pass a Model (lets say it's an actor model) to a sub layout that extends the master, and i want to be able to fill this mark up.
Due to the amount of data, using sections/ Yield would need too many sections (title, desc, type, image url, image width, etc...)

master.blade.php

  • include('opengraph')
  • include('ld+json')
  • include('twitter')
  • yields('content)

sublayout.blade.php

  • extends('master')
  • section('content')

I know there are View Composers, which seem the logical way to do this, But i cannot find how to inject the Model in to the view composer.

Is there a way to pass data to the master layout? either with or without a View Composers. Or is there another different way to do this?

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

etaion etaion Joined 25 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.