title: Why eloquent model relationships do not use parenthesis and how do they work?
body: <p>I kept searching the web for an hour but couldn't figure this out. If we look at the eloquent relationships documentation:
  <a href="https://laravel.com/docs/5.2/eloquent-relationships" rel="noreferrer">https://laravel.com/docs/5.2/eloquent-relationships</a></p>
  
  <p>The example User model:</p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class User extends Model
  {
      /**
       * Get the phone record associated with the user.
       */
      public function phone()
      {
          return $this-&gt;hasOne('App\Phone');
      }
  }
  </code></pre>
  
  <p>Just below it, how to access the phone number of a user with id=1:</p>
  
  <pre><code>$phone = User::find(1)-&gt;phone;
  </code></pre>
  
  <p>Why is it <code>phone</code> and not <code>phone()</code> and what is the difference?</p>
  
  <p>Also how does it work? If I try to call an <code>object-&gt;name</code> without parenthesis in my code PHP thinks I am looking for a class variable named <code>name</code>?</p>
  
  <p>Some extra information:</p>
  
  <p>It looks like phone is returning object(App\Models\Phone) and phone() is returning object(Illuminate\Database\Eloquent\Relations\HasOne)</p>
  
  <p>If I run the code below:</p>
  
  <pre><code>User::find(1)-&gt;phone-&gt;count()
  </code></pre>
  
  <p>Framework executes following SQL statements:</p>
  
  <pre><code>select * from `phone` where `phone`.`user_id` = '1' and `phone`.`user_id` is not null limit 1
  select count(*) as aggregate from `phone`
  </code></pre>
  
  <p>If I run the code below:</p>
  
  <pre><code>User::find(1)-&gt;phone()-&gt;count()
  </code></pre>
  
  <p>Framework executes following SQL statement:</p>
  
  <pre><code>select count(*) as aggregate from `phone` where `phone`.`user_id` = '1' and `phone`.`user_id` is not null
  </code></pre>