title: @include a view with controller functionality - Laravel 5.4
body: <p>I am working on a profile page for my web application. Within this view <code>profile.blade.php</code> I would like to include the view <code>progress/index.blade.php</code>. I have the following structure:</p>
  
  <blockquote>
    <p>profile.blade.php</p>
  </blockquote>
  
  <pre><code>&lt;div class="panel panel-default"&gt;
          &lt;div class="panel-heading clearfix"&gt;
              &lt;h1 class="panel-title pull-left"&gt;{{ $user-&gt;name }} Progress&lt;/h1&gt;
          &lt;/div&gt;
          &lt;div class="panel-body"&gt;
              @include('client.progress.index')
          &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <blockquote>
    <p>web.php</p>
  </blockquote>
  
  <pre><code>Route::group(['middleware' =&gt; ['auth', 'client'], 'prefix' =&gt; 'client', 'as' =&gt; 'client.'], function () {
      Route::get('home', 'Client\HomeController@index')-&gt;name('home');
      Route::get('profile', 'Client\UserController@profile')-&gt;name('profile');
      Route::get('progress', 'Client\UserController@progress')-&gt;name('progress.index');
  });
  </code></pre>
  
  <blockquote>
    <p>UserController@progress</p>
  </blockquote>
  
  <pre><code>public function progress(){
  
          $auth = Auth::user();
          $progressPictures = Picture::select('*')
              -&gt;where('user_id', $auth-&gt;id)
              -&gt;get();
  
          return view('client.progress.index', ['progressPictures' =&gt; $progressPictures]);
      }
  </code></pre>
  
  <blockquote>
    <p>client.progress.index</p>
  </blockquote>
  
  <pre><code>&lt;p&gt;Progress pictures&lt;/p&gt;
  
  @foreach($progressPictures as $progressPicture)
      &lt;img src="/storage/uploads/progress/{{ $progressPicture }}" style="width:150px; height:150px; float:left; border-radius:50%; margin-right:25px;"&gt;
  @endforeach
  </code></pre>
  
  <p>When I remove the php part from the <code>index.blade.php</code>, the site works. but when i add the <code>foreach</code> loop, <code>$progressPictures</code> is undefined. I am not calling the <code>UserController@progress</code> in some way. Could some one help me with this? </p>