title: How to get min price of products from categories laravel
body: <p>I have model category with relations:</p>
  
  <pre><code>public function attribute()
  {
      return $this-&gt;hasMany('App\Models\Attribute');
  }
  
  public function children()
  {
      return $this-&gt;hasMany(self::class, 'parent_id');
  }
  
  public function products()
  {
      return $this-&gt;hasMany('App\Models\Product');
  }
  </code></pre>
  
  <p>How I can get min price of products from children categories (if exists).</p>
  
  <p>This code:</p>
  
  <pre><code>$category = Category::whereId('id', $categoryId)-&gt;first();
  if($category-&gt;children) $products = $category-&gt;children()-&gt;products()-&gt;min('price'); }
  </code></pre>
  
  <p>not working. I get error: </p>
  
  <pre><code>Method Illuminate\Database\Query\Builder::products does not exist. (View: 
  </code></pre>