title: How to get products from database using pivot category table and run another query on the retrieved products in laravel?
body: <p>I have a product table and a category table and the category_product table. I want to get products of a specific category then run an other query on the retrieved products using a column that belongs to products table. for example all products that belongs to mobile category and have price less than 1000$. how can i do that? and second question: how to add pagination to it?</p>
  
  <p><strong>UPDATE: solved</strong></p>
  
  <p>with a query like this:</p>
  
  <pre><code>$products = Category::where(['title' =&gt; 'mobile'] )-&gt;first()-&gt;pictures()-&gt;where('price', '&lt;' , 1000)-&gt;latest()-&gt;paginate(10);
  </code></pre>