vendredi 11 décembre 2020

Attempt to read property "total_product_quantity" on null

I make a Nested loop which i create a view for show my data. how can i show data of single query in view. This is my View page

 @foreach($products1 as $item1)          <!-- first product loop -->
                  <tr>
                    <td></td>
                    <td></td>
                    @foreach($products2 as $item2)  <!-- second product loop -->

                      @if($item1->id == $item2->id)       <!-- campare with second one -->

                        @for($k=1;$k<=31;$k++)             <!-- loop for days -->
                          <td id="">
                            
                          </td>  
                        @endfor

                      @endif

                    @endforeach
                  </tr>
                  @endforeach

this is controller code

public function index($id)
{
    
    $products1 = Product::get();
    $products2 = Product::get();
    $data['dispatch'] = Production_log::where('employee_id','=',$id)->get();
    $dispatch = '01'.'-'.'12'.'-'.'2020';
    
    return view('production.index',compact('products1','products2','data'));
}

Error message
my result query


**This is my raw output **

{"total_product_quantity":"6"}

I need this output


view output

5


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire