title: Laravel: How to share variables with parent view
body: <p>I do have the current state that I have multiple projects in my Laravel application (which are stored in a database). I do have the following URL structure:</p>
  
  <p><a href="http://app.com/project/7-exampleproject/news" rel="nofollow noreferrer">http://app.com/project/7-exampleproject/news</a></p>
  
  <p>where</p>
  
  <p><a href="https://app.com/project/" rel="nofollow noreferrer">https://app.com/project/</a>{id}-{seostring}/{module}</p>
  
  <p>Is the idea behind it. What I do need is that the project variable should be available on any view (module) which comes after the {id} part. How can I achieve it?</p>
  
  <p>==</p>
  
  <p>Additional information</p>
  
  <p>Here is the route list:</p>
  
  <pre><code>GET|HEAD | project/{project}{extra?} | project.dashboard.index | App\Http\Controllers\Project\DashboardController@index | web
  
  GET|HEAD | project/{project}{extra?}/news | project.news.index | App\Http\Controllers\Project\NewsController@index | web
  
  GET|HEAD | project/{project}{extra?}/tournaments | project.tournaments.index | App\Http\Controllers\Project\TournamentController@index | web
  
  
  Route::group(['prefix' =&gt; 'project', 'namespace' =&gt; 'Project'], function(){
  Route::get('/{project}{extra?}', 'DashboardController@index')-&gt;name('project.dashboard.index')-&gt;where(['id', '[0-9+]','extra' =&gt; '-[A-Za-z0-9]+']);
  Route::get('/{project}{extra?}/news', 'NewsController@index')-&gt;name('project.news.index')-&gt;where(['id', '[0-9+]','extra' =&gt; '-[A-Za-z0-9]+']);
  Route::get('/{project}{extra?}/tournaments', 'TournamentController@index')-&gt;name('project.tournaments.index')-&gt;where(['id', '[0-9+]','extra' =&gt; '-[A-Za-z0-9]+']);
  </code></pre>
  
  <p>});</p>
  
  <p>In each of those views my app.layouts.project gets extended by the content of each, so we end up with:</p>
  
  <pre><code>@extends('layouts.project')
  
  @section('content')
  &lt;h3&gt;Welcome to &lt;br&gt;{{ $project-&gt;name }}!&lt;/h3&gt;
  @endsection
  </code></pre>
  
  <p>But what I want to achieve is, EACH time the /project/{project} gets called, the view layouts.project should get it's active ID and $project variable</p>
  
  <p>==</p>
  
  <p>How I want the data to be available:</p>
  
  <p>In my case, each module currently gets the active project from the URL (as seen on the dashboard here), already from the URL. This is not what I am looking for.</p>
  
  <pre><code>public function index(Project $project)
  {
      return view('project.dashboard.index',[
          'project' =&gt; $project
      ]);
  }
  </code></pre>
  
  <p>What I am looking for is to include the $project object (including all information) to layouts.project, which includes meta and head title informations, as well as displaying the project name itself.</p>