DEV Community

Fidelis Solomon
Fidelis Solomon

Posted on

Building an e-commerce website with Laravel

I'm currently building, a B2C (Business to Consumer) e-commerce website, for a fashion store. In this article, I'll tell you the steps that i've taken to build to project, to completion, the project's time frame, what tools i'm using to build it and where i'm at with building the project.

Let's start by clarifying 3 things:

1. what is an e-commerce website?

E-commerce (electronic commerce) is the buying and selling of goods and services, or the transmitting of funds or data, over an electronic network, primarily the internet. An E-commerce website, advertises / displays the "goods" or "services" for sale, allows the visitor to choose the products they reuqired and faciliates the payment process, in exchange for goods or services sold. It's also possible to sometimes track the order / delivery process, on the website.

2. examples of e-commerce websites

Good examples of e-commerce websites, just so that you have an real world examples to go with the explanation above would be,
a. jumia.com
b. konga.com
c. amazon.com
d. alibaba.com
e. etc.

3. examples of B2C e-commerce websites

B2C stands for (Business to Consumer). Examples of B2C e-commerce websites include, alibaba.com,
a. dominos.ng
b. amazon.com
c. shopify.com
d. alibaba.com
e. etc.

Since we now understand understand what i mean by a "B2C e-commerce website". Let me give you details about the project and walk you through the process which i've followed to build the website.

The website that i'm working on, is called "Sleekfashion (a unisex online fashion store)". I've been building it now, for the past 1 month. This is the second project, that I'll be building with the "Laravel framework". The first was a blog, called "wethepeople", you can find it on my portfolio "thesolomonfidelis.com".

Let me walk you through the steps that i've taken so far:

1. I found an e-commerce template'

I found a template called (Majestic), it's a bootstrap template, i found it on (). It was perfect for what i wanted, an online fashion store.

Image description

2. I studied the template and used, what was on it to design my database

I'm using mySql, as my database driver. The data on an e-commerce website typically contains tables, for Users, Products, Categories, Shopping_Cart, Wishlist, Orders, etc.

3. I created a Laravel project

I already went through this process, when i built a blog using the "laravel beginner lesson" on Laracast.com, so this part was straightforward. The laravel project, which i created was named, "sleekfashion". You can find a guide for how to create a Laravel project, on the official documentation for it's framework here ().

NOTE: If you want to know why people choose laravel or why i think it's perfect for an e-commerce application or "enterprise level applications". You can find your reasons here ().

4. I created my database, using Laravels Database migrations

I particularly like this feature. I got to skip writing "sql queries", to create a database. You can find a guide on how to do that here ().

5. I created my test data, using Laravels Database Factory and Filled my database with the "Database Seeder" Class

This allows me to fill the database, which i already created, with fake data.

6. I created my Models

Laravel allows you to create a model to map the database to your application, using "Eloquent ORM (Object Relational Mapper)". You can generate a model for each table in your database, and it automatically links that table to it's model (as long as they bear the same name, else you'd have to specify). This allowed me to skip the normal process of manually trying to create "select, insert, delete, etc." statements and to build a model class for each table, before i start my project. I've initially build large projects, using Php and this was enjoyable, to say the least.

7. I created my Controllers

Each model can be linked to a controller, which would hold the back-end logic, that receives your requests and tells your web application, what to do with the data that's available in your database, based on your request.

8. I created a View

Remember earlier when, i told you that i used an e-commerce template. I had to take the template apart and include it into my project, in order to start working on it. In Laravel "views" provide a convenient way to place all of our HTML in separate files.

9. I'm still working on it

You can check out my portfolio... thesolomonfidelis.com, for the other projects, which i've worked on.

CONCLUSION:

Laravel is a web application framework, that's built on PHP. It allows developers to build fully functional web applications, without having to focus on a lot of the details. Like you would, if you were working with only PHP. If you'd like to learn how to use Laravel, I'd recommend starting with Laracast's video course (Laravel 8 from scratch), you can find it (IT'S FREE!) and would save you a lot of time and stress, also it's how i learnt. Until next time, I'm Solomon "Solzycode" Fidelis.

Top comments (0)