lundi 5 juin 2017

How to generate more than specific column in Laravel Blade

In my case it's all about pricing table.

Usually specific column in pricing table is 3

So by default is I can create more than 3 pricing but it will break the view because the view is designed for 3 pricing column in a row.

Usually I do this in view

<Div class="row">
@foreach($products as $product)
<Div class="col">
Pricings detail goes here.
</Div>
@endforeach
</Div>
<Div class="clear break"></div>

So If pricing is 3 the view will be ok, but it will break if pricing more than 3.

How I can deal with this situation?

My logic so far is create new row and clear break class if pricings divided by 3 is decimal like this simulation.

Pricings 3 div by 3 = 1 row n 1 clear break

Pricings 4 div by 3 = 1.xx so 2 row n 2 clear break

Pricings 6 div by 3 = 2 so 2 row n 2 clear break

Pricings 8 div by 3 = 2.xx so 3 row n 3 clear break

With above logic it should not break the view.

Thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire