title: Accessing parent value inside Eloquent Relation
body: <p>In my controller,</p>
  
  <pre><code>User::find(1)-&gt;with('matches')-&gt;get()
  </code></pre>
  
  <p>And in the Model,</p>
  
  <pre><code>public function matches()
  {
      $userAge = $this-&gt;age; // Trying to access something like this
  
      return $this-&gt;hasMany('App\Others', 'location', 'location')
                  -&gt;selectRaw('*, ('.$userAge.' = age) as match');
  }
  </code></pre>
  
  <p>How can I access the User's age like <code>$this-&gt;age</code>? Or Is that even possible? I already tried to <code>var_dump($this)</code> to see what I can get, but no luck.</p>
  
  <p>My original goal was to inner join the <code>User</code> and <code>Others</code> table/model.
  I have a query like this:</p>
  
  <pre><code>SELECT (a.age = b.age) as match
  FROM user a 
  LEFT JOIN others b ON a.location= b.location 
  WHERE a.location = 'Somewhere' 
  </code></pre>
  
  <p>I know I can do it easily with Query builder, but I think it is better if I can do it using Eloquent/Relationships.</p>
  
  <p>Hope you guys get my point.</p>
  
  <p>I'm still new in Laravel.</p>