Multilingual E-commerce API using Laravel 8.0 – Setup

In this tutorial series we will be building a E-commerce API using Laravel 8.0.

You will need to setup the following:

  • Laravel 8.0 on your machine (Mac setup, Windows setup, Linux setup)
  • Postman API testing tool

Once you have setup Laravel on your system its time to create the basic application.

We first need to create a resourceful endpoint. So lets create an endpoint for products. This endpoint will allow us to define CRUD operations (CREATE, EDIT, DELETE and VIEW products).

# Step 1

Go to the project root directory using your terminal window and type the following command

php artisan make:model Products -a

The -a flag will generate a migration, seeder, factory, and resource controller for the products model

If you go to your project folder you should see the following files created by executing the above command. The files will have a lot of boilerplate code generated by Laravel for you.


If your model file Product.php was created outside of your model directory then simple copy the Product.php file in the model directory and change the namespace at the top.

from namespace App;

to namespace App\model;

Older versions of Laravel does not have the app/Model folder by default. If you don’t see a model folder then create it inside your app/ directory.

# Step 2

We will also need other models such as the productTranslations, Language and Category. Use the following commands to create all the relevant files.

php artisan make:model ProductTranslations -a
php artisan make:model Language -a
php artisan make:model Category -a

The above commands will create the productTranslation, Language and Category resources along with their migrations, seeders, factories and resource controllers.

Now that we have the initial setup done let’s create the database migrations

Series NavigationMultilingual E-commerce API using Laravel 8.0 – Part 2 Database Migrations >>