title: Attempt to read property "total_product_quantity" on null
body: <p>I make a Nested loop which i create a view for show my data.
  how can i show data of single query in view.
  <a href="https://i.stack.imgur.com/1u2uD.jpg" rel="nofollow noreferrer"><strong>This is my View page</strong></a></p>
  <pre><code> @foreach($products1 as $item1)          &lt;!-- first product loop --&gt;
                    &lt;tr&gt;
                      &lt;td&gt;{{++$i}}&lt;/td&gt;
                      &lt;td&gt;{{$item1-&gt;productname}}&lt;/td&gt;
                      @foreach($products2 as $item2)  &lt;!-- second product loop --&gt;
  
                        @if($item1-&gt;id == $item2-&gt;id)       &lt;!-- campare with second one --&gt;
  
                          @for($k=1;$k&lt;=31;$k++)             &lt;!-- loop for days --&gt;
                            &lt;td id=&quot;&quot;&gt;
                              {{$log =App\Models\Production_log::select('total_product_quantity')-&gt;where('product_id',$item2-&gt;id)-&gt;where('employee_id','3')-&gt;where('log_date',$k.'-'.'12'.'-'.'2020')-&gt;first() }}
                            &lt;/td&gt;  
                          @endfor
  
                        @endif
  
                      @endforeach
                    &lt;/tr&gt;
                    @endforeach
  </code></pre>
  <p><strong>this is controller code</strong></p>
  <pre><code>public function index($id)
  {
      
      $products1 = Product::get();
      $products2 = Product::get();
      $data['dispatch'] = Production_log::where('employee_id','=',$id)-&gt;get();
      $dispatch = '01'.'-'.'12'.'-'.'2020';
      
      return view('production.index',compact('products1','products2','data'));
  }
  </code></pre>
  <hr />
  <p><a href="https://i.stack.imgur.com/IOeDY.jpg" rel="nofollow noreferrer">Error message</a><br>
  <strong>my result query</strong></p>
  <pre><code>{{$log =App\Models\Production_log::select('total_product_quantity')-&gt;where('product_id',$item2-&gt;id)-&gt;where('employee_id','3')-&gt;where('log_date',$k.'-'.'12'.'-'.'2020')-&gt;first() }}
  </code></pre>
  <p>**This is my raw output **</p>
  <pre><code>{&quot;total_product_quantity&quot;:&quot;6&quot;}
  </code></pre>
  <p><strong>I need this output</strong></p>
  <pre><code>{{$log-&gt;total_product_quantity}}
  </code></pre>
  <p>view output</p>
  <pre><code>5
  </code></pre>