title: Defining global variable in laravel
body: <p><strong>Model: Comment.php</strong></p>
  
  <pre><code>class Comment extends Eloquent {
      protected $table = 'comments';
      public $timestamps = true;
  }
  </code></pre>
  
  <p><strong>Controller: PageController.php</strong></p>
  
  <pre><code>class PageController extends BaseController {
      $top_comments = Comment::take(3)-&gt;get();
      return View::make('page', array('top_comments' =&gt; $top_comments));
  }
  </code></pre>
  
  <p><strong>View: page.blade.php</strong></p>
  
  <pre><code>@foreach ($top_comments as $comment)
      user #{{ $comment-&gt;user_id }}:&lt;br /&gt;
      {{ $comment-&gt;comment}}
  @endforeach
  </code></pre>
  
  <p>This works perfect with the <code>page.blade.php</code> view which I can define as a route (<code>/page</code>). However, I can't seem to figure out how to achieve this globally.</p>
  
  <p>Example: I want to be able to use the <code>@foreach</code> containing <code>$top_comments</code> in my <code>master.blade.php</code> file. Right now if I was to use the above, it works great on <code>/page</code> but not on <code>/</code>, <code>/about</code>, <code>/tos</code></p>