Rifat
Rifat

Reputation: 27

Nested foreach in Laravel

In my code I have a nested foreach, but when run it shows this error Screenshot of error message

Here is my code:

@foreach ($product as $user)

<p>This is title {{ $user->title }}</p>
<p>This is category {{ $user->category }}</p>
<p>This is sub category {{ $user->sub_category }}</p>

@foreach ($product_image as $product_image)
<p>This is image {{ $product_image->p_image }}</p>
@endforeach

@endforeach

Upvotes: 1

Views: 767

Answers (1)

Ferran
Ferran

Reputation: 142

The second foreach sould be:

@foreach ($User->product_images as $product_image)

an not:

@foreach ($product_image as $product_image)

Upvotes: 1

Related Questions