title: Puling a specific item from a foreach loop in Laravel
body: <p>I have a project with 2 tables(Categories and products). They have One to Many relationship. Many products have one Category. Am pulling products of a specific category(together with its price and description) and storing in one variable so that I can use in the view. In the view am having a foreach loop whereby I want to display each row from the products table of a specific category(a product with its price and description) but it fails,,please assist?</p>
  
  <p>FrontController</p>
  
  <pre><code>public function itemOne() {
      //Get all phones(Have category of 1 ) in categories table
      $mobile = Category::find(1)
          -&gt;products()
          -&gt;whereNotNull("image")
          -&gt;whereNotNull("name")
          -&gt;whereNotNull("description")
          -&gt;whereNotNull("price")
          -&gt;whereNotNull("category_id")-&gt;get();
  
      return view('front.products')-&gt;withItems($mobile);
  }
  </code></pre>
  
  <p>Products.blade.php</p>
  
  <pre><code>@foreach($items as $item)
                  &lt;img src="{{ asset('images/'.$item-&gt;image) }}"&gt;
      &lt;br&gt; {{  $item-&gt;name}} &lt;br&gt; {{ $item-&gt;price }}
  @endforeach
  </code></pre>