Skip to main content

Laravel 5.4 Bootstrap row class for every 3 columns

Sometimes you need to show three or four columns in a row using Laravel 5.4 and blade template engine.

Here I show how to do it using chunk function in Laravel blade.

As the first step let's get products from the database and pass it to the blade view.

And let's check our blade file. In the following example, @foreach takes the $products array and chuck it. In this example, I split it by three. You can pass any number according to your specification.

And you will see the inner @foreach loop through $items.
If you have any question please comment it and I will try to solve it.

Comments

Popular posts from this blog

Alternatives to the SQLite in Android

At the moment there are several embeddable databases and libraries out there that you can use in a mobile application. In this post, I examine most popular libraries and databases and highlight some of their characteristics. Realm Realm is a mobile platform and a replacement for SQLite & Core Data. According to the website, it has more than 100k active developers. Realm is fully open source and distributes under Apache License. Realm Mobile Database is much faster than an ORM, and often faster than raw SQLite due to zero-copy design. Some of the benefits of Realm are fast queries, safe threading, encryption of data and reactive architecture. You can learn more about Realm by visiting this page . Sugar ORM Sugar ORM is a library that can be used to interact with SQLite database using Object-Relational Mapping. Object-Relational Mapping (ORM) is a technique that used to query and manipulate data from a SQLite database using an object-oriented paradigm. And Sugar ORM tak

Deploy Laravel 5.4 App on LEMP Stack (DigitalOcean Guide) Part - 1

This blog post teaches you how to set up Laravel onto a virtual private server (VPS) using LEMP stack (DigitalOcean). LEMP is an acronym that stands for Linux, Nginx (Engine-X), MySQL and PHP. The reason I chose to use LEMP with Laravel is that it seems to be the preferred stack among the Laravel community. You can use LAMP stack as well, but when running smaller server instances like we are (with 512mb RAM), it has shown that Nginx performs better with limited resources. Why DigitalOcean? You can host it any VPS server that you wish. In this tutorial, I set up the server through SSH into VPS instance. But there are few reasons to choose DigitalOcean such as simple UI and minimalistic approach, SSD-based virtual machines, comprehensive documentation, affordable pricing and community & ecosystem Support. I have used DigitalOcean in production, and it works great. If you would like to sign up using Busy Programmer's Guide, you will get $10 to get started, absolutely free.