mercredi 11 novembre 2020

Laravel IF/Foreach statement

I am currently trying to write a IF/foreach statment for scenario but im having a little trouble writing the correct syntax.

so currently I have a page which lists all the products that are currently purchased within a foreach which displays all the products within a boostrap card using this code within the blade.

@foreach($user->products()->where('purchased', 1)->get() as $product)

for each product it includes a field called includes_bonus which is a true or false value. If the value is true it then turns the product with the id of 2 to purchased also.

I am wanting to create a loop where if a product e.g with the id of 5 is purchased and it has the includes_bonus set to true it displays the product with the id of 5 on the page but it doesn't show the includes_bonus which is an id of 2 on the page because its part of a bulk buy but if you was purchase the product with the id of 2 individually it would then show.

Aucun commentaire:

Enregistrer un commentaire