O'Reilly logo

Laravel Application Development Cookbook by Terry Matula

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building a shopping cart

E-commerce is a huge business on the web. An integral part of most e-commerce sites is the use of a shopping cart system. This recipe will walk through how to use Laravel sessions to store items for sales and build a shopping cart.

Getting ready

For this recipe, we need a standard installation of Laravel, as well as a properly set up and configured MySQL database.

How to do it...

To complete this recipe, follow these given steps:

  1. In our database, create a table and add some data with this SQL code:
    CREATE TABLE items ( id int(10) unsigned NOT NULL AUTO_INCREMENT, name varchar(255) DEFAULT NULL, description text, price int(11) DEFAULT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB; INSERT INTO items VALUES ('1', 'Lamp', 'This is a Lamp.','14'); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required