title: Showing results of a database query inside Navigation Tab
body: <p>I want to show the results of a database query inside the navigation tab of the home page. How do I call the $results variable inside the posts tab of the home page (the last code block). Thanks</p>
  
  <p>PostController.php</p>
  
  <pre><code>class NoteController extends Controller
  {
  /**
   * Display a listing of the resource.
   *
   * @return \Illuminate\Http\Response
   */
  public function index()
  {
      $posts = DB::select(....);
  return view('posts.index',['results' =&gt; $posts]);
  }
  </code></pre>
  
  <p>The post index blade</p>
  
  <pre><code>@extends('layouts.app')
  
  @section('content')
  
  &lt;div class="container"&gt;
    &lt;div class="col-md-8"&gt;
      @foreach($results as $notes)
        &lt;div class="panel panel-default"&gt;
          &lt;div class="panel-body"&gt;
            {{$notes-&gt;note}}
          &lt;/div&gt;
        &lt;/div&gt;
      @endforeach
    &lt;/div&gt;
  &lt;/div&gt;
  
  @endsection
  </code></pre>
  
  <p>The home index file</p>
  
  <pre><code>@extends('layouts.app')
  
  @section('content')
  &lt;div class="container"&gt;
   &lt;ul class="nav nav-tabs"&gt;
      &lt;li class="active"&gt;&lt;a data-toggle="tab" href="#posts"&gt;Posts&lt;/a&gt;&lt;/li&gt;
      &lt;div class="tab-content"&gt;
        &lt;div id="posts" class="tab-pane fade in active"&gt;
        &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  @endsection
  </code></pre>