Skip to content

Laravel eCommerce API along with Passport authentication.

Notifications You must be signed in to change notification settings

javedbaloch4/laravel-ecommerce-api

Repository files navigation

# Laravel eCommerce API

This Project is based on Laravel & Laravel Passport, Practising eCommerce API.

Installation

> git clone https://github.com/javedbaloch4/laravel-ecommerce-api.git
> composer install
> cp .env.example .env // This will is make copy of env. 
  • copy command on windows & cp for Linux
  • Setup .ev file and add DB credt.
> php artisan migrate --seed
> php artisan passport:install
> php artisan make:auth
> php artisan key:generate // Generate if not exists in .env
> php artisan serve
Register a user

Postman Instructions

Config OAuth

POST Req : http://localhost:8000/oauth/token

Headers: 
   Content-type : application/json
   Accept: application/json

Body:
{
    "grant_type" : "password",
    "client_id" : "2",
    "client_secret" : "copy key from table oatuh_client > secret",
    "username" : "Reg email", 
    "password" : "Reg Password"
}
  • This will return a token add this in Postman env var or paste in Authorization value.

Headers

Headers will be almost common everywhere, manuallay disable auth val.
Headers: 
   Content-type : application/json
   Accept: application/json
   Authorization: {{auth}} from postman env var.
 

APIs

Products APIs

All Products
GET http://localhost:8000/api/products
Show Product
GET http://localhost:8000/api/products/33
Edit Product
PUT http://localhost:8000/api/products/31

Body
{
    "name" : "Iphone 9c Update",
    "detail" : "Best new phone for charging ",
    "price" : "900",
    "stock" : "5",
    "discount" : "10"
}
Delete Product
DELETE http://localhost:8000/api/products/31

Reviews APIs

Show A Review
GET http://localhost:8000/api/products/32/reviews
Create A Review
POST http://localhost:8000/api/products/39/reviews/139

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.