title: Laravel get model attribute: difference between two methods
body: <p>I found out that there are two ways to get/display a model's attribute with Laravel. I could create a function in <code>User.php</code> for example:</p>
  
  <pre><code>public function getUsername() {
      return $this-&gt;username;
  }
  </code></pre>
  
  <p>Then display the username like this:</p>
  
  <pre><code>{{{ Auth::user()-&gt;getUsername() }}}
  </code></pre>
  
  <p>Or I could just simply do this without needing to create a function:</p>
  
  <pre><code>{{{ Auth::user()-&gt;username }}}
  </code></pre>
  
  <p>What is the difference between these two methods?</p>