title: How to pass parameter in Laravel model relation
body: <p>I made a category tree and I need to pass one parameter to relation, I can't pass them.</p>
  
  <pre><code>public function Child()
  {
      return $this-&gt;hasMany(Category::class, 'parent_id', 'id');
  }
  </code></pre>
  
  <p>but I want to use variable to pass in relation look like this.</p>
  
  <pre><code>public function Child()
  {
      return $this-&gt;hasMany(Category::class, 'parent_id', 'id')-&gt;where(['owner_id' =&gt; $this-&gt;ownerId]);
  }
  </code></pre>
  
  <p>then I try to use variable and receive nothing, but if I use hardcoded value then works well. Please help</p>