title: Dynamic properties with ManyToOne (Laravel4/Eloquent)
body: <p>I have a pretty basic relationship wherein searches are logged and stored along with the ID of the user who performed the search.</p>
  
  <p>I'm trying to output this log and display the username instead of the id.</p>
  
  <p><strong>Search</strong></p>
  
  <pre><code>public function user()
  { 
      return $this-&gt;belongsTo('User');
  }
  </code></pre>
  
  <p><strong>User</strong></p>
  
  <pre><code>public function searches()
  { 
      return $this-&gt;hasMany('Search');
  }
  </code></pre>
  
  <p>If I then pass <code>Search::all();</code> to the view, how can I echo the username? Among many other things, I've tried:</p>
  
  <pre><code>@foreach($searches as $search)
      &lt;tr&gt;
          &lt;td&gt;{{ $search-&gt;user-&gt;username }}&lt;/td&gt;
          &lt;td&gt;{{ $search-&gt;description }}&lt;/td&gt;
          &lt;td&gt;{{ $search-&gt;product }}&lt;/td&gt;
          &lt;td&gt;{{ $search-&gt;group }}&lt;/td&gt;
      &lt;/tr&gt;
  @endforeach
  </code></pre>
  
  <p>Any help is much appreciated. Thanks!</p>