jeudi 29 avril 2021

how to loop through data from many to many relationship laravel?

i am trying to get the name of the supplier of each product but when i do this

 @foreach ($products as $product )
    <tr>
      <th scope="row"></th>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
@endforeach

it says Property [name] does not exist on this collection instance however when i do this

<td></td>

this is what is what it shows me [{"id":1,"name":"test","address":"test","created_at":null,"updated_at":null,"pivot":{"product_id":1,"supplier_id":1}}]

so i think the relationship exists i just cant figure out how to loop through it

side note : i did indeed insert data through phpmyadmin and not seed ,



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2QxWWzH
via IFTTT

Aucun commentaire:

Enregistrer un commentaire