Postingan lainnya
Kelas Premium!
Belajar bikin website dari nol sekarang
Gunakan kupon "lebihcepat" untuk diskon 25%!
Laravel, html, css: cara menampilkan data horizontal (tidak pakai table)
Sekarang hasilnya begini
q
w
e
r
t
y
u
i
Maunya kaya gini
q w e
r t y
u i
@foreach ($kategori as $k)
<div class="row justify-content-center">
<div class="col-lg-4">
<p id="link">
<a class="text-dark me-2" href="#{{ $k->slug }}">
<code class="text-danger"><i class="fa-solid fa-chevron-down opacity-70"></i></code><span> {{ $k->kategori }}</span>
</a>
</p>
</div>
</div>
@endforeach
1 Jawaban:
Jawaban Terpilih
<div>Sudah ketemu gan, pakai method chunk.<br>https://laravel.com/docs/9.x/collections#method-chunk<br><br></div><pre>@foreach ($kategori->chunk(3) as $chunk) <div <em>class</em>="row justify-content-center"> @foreach ($chunk as $k) <div <em>class</em>="col-lg-4"> <p <em>id</em>="link"> <a <em>class</em>="text-dark me-2" <em>href</em>="#{{ $k->slug }}"> <code <em>class</em>="text-danger"><i <em>class</em>="fa-solid fa-chevron-down opacity-70"></i></code><span>&nbsp;{{ $k->kategori }}</span> </a> </p> </div> @endforeach </div> @endforeach</pre>