This code works, however in my learning of Laravel, I want to know if using Blade+Laravel syntax, can be better implemented
@for ($i = 0; $i <= (5 - $post->images->count()); $i++)
<div class="col"> </div>
@endfor
https://laravel.com/docs/5.5/blade#loops
I would suggest using a for loop instead of a while loop in this case:
@for ($i = 1; $i <= (5 - $post->images->count()); $i++)
<div class="col"> </div>
@endfor
@php
$i = 0;
@endphp
@while (++$i <= (5 - $post->images->count()))
<div class="col">
</div>
@endwhile
I'm not sure is the best way to do, but works.
<?php $z = 0; ?>
@while ($z < 3)
{{ "test".$z }}
<?php $z++ ?>
@endwhile
Yes, there is. Templating is made just for that, you can see how similar things are done with the docs : laravel blade : loops
@for ($i = 0; $i < $post->images->count()); $i++)
<div class="col"> </div>
@endfor
The better solution would be to use @foreach
@foreach( $image as $post->images )
<div class="col"> </div>
@endforeach