GithubHelp home page GithubHelp logo

pizzavel's Introduction

Laravel - Api Simples Pizzaria - Teste Hotmilhas

Construa uma API REST simples para uma pizzaria, a linguagem da API é livre, a aplicação que consumir a sua API deve ser capaz de incluir, alterar ou excluir pizzas com tamanhos e sabores variados, também deve ser capaz de criar pedidos para os clientes. Dica: utilize o número do telefone do cliente para identifica-lo e não se esqueça de armazenar o endereço de entrega.

Installation

Renomear .env.example para .env e configuere o banco de dados

Config Data Base

DB_CONNECTION=mysql
DB_HOST=
DB_PORT=
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=

Run

composer install

Run

php artisan migrate

REST APIs

- Criar categoria POST /category
- Listar todas categorias GET /category
- Exibir uma categoria especifica GET /category/{id}
- Atualiar uma categoria PUT /category/{id}
- Remover uma categoria DELETE /category/{id}
- Criar produto POST /product
- Listar todos produtos GET /product
- Exibir um produto especifico GET /product/{id}
- Atualiar um produto PUT /product/{id}
- Remover um produto DELETE /product/{id}
- Criar sabor POST /flavor
- Listar todos sabores GET /flavor
- Exibir um sabor especifico GET /flavor/{id}
- Atualiar um sabor PUT /flavor/{id}
- Remover um sabor DELETE /flavor/{id}
- Criar cliente POST /client
- Listar todos clientes GET /client
- Exibir um cliente especifico GET /client/{telephone}
- Atualiar um cliente PUT /client/{telephone}
- Remover um cliente DELETE /client/{telephone}
- Criar pedido POST /order
- Listar todos pedidos GET /order
- Exibir um pedido especifico GET /order/{id}
- Remover um pedido DELETE /order/{id}

Request & Response Examples

/category

POST /category

Request:

{
    "name" : "Pizza"
}

GET /category

Response:

[  
   {  
      "id":1,
      "name":"Pizza",
      "created_at":"2019-06-27 18:31:00",
      "updated_at":"2019-06-27 18:31:00"
   },
   {  
      "id":2,
      "name":"Bebidas",
      "created_at":"2019-06-27 19:51:10",
      "updated_at":"2019-06-27 19:51:10"
   }
]

GET /category/id

Response:

{  
   "id":2,
   "name":"Bebidas",
   "created_at":"2019-06-27 19:51:10",
   "updated_at":"2019-06-27 19:51:10"
}

PUT /category/id

Response:

{  
   "name":"Bebidas"
}

DELETE /category/id

Response:

status code 200

/product

POST /product

Request:

 {  
   "name":"Pizza Grande",
   "price":19.99,
   "category_id":1
}

GET /product

Response:

[
  {
    "id": 1,
    "name": "Pizza Grande",
    "price": 19.99,
    "category_id": 1,
    "created_at": "2019-06-28 00:17:52",
    "updated_at": "2019-06-28 00:17:52",
    "flavor": [
      {
	"id": 1,
	"name": "mussarela",
	"category_id": 1,
	"created_at": "2019-06-27 19:37:22",
	"updated_at": "2019-06-27 19:37:22"
      },
      {
	"id": 2,
	"name": "napolitana",
	"category_id": 1,
	"created_at": "2019-06-27 20:37:35",
	"updated_at": "2019-06-27 20:37:39"
      },
      {
	"id": 3,
	"name": "portuguesa",
	"category_id": 1,
	"created_at": "2019-06-27 20:37:50",
	"updated_at": "2019-06-27 21:37:50"
      }
    ],
    "category": {
      "id": 1,
      "name": "Pizza",
      "created_at": "2019-06-27 18:31:00",
      "updated_at": "2019-06-27 18:31:00"
    }
  },
  {
    "id": 2,
    "name": "Pizza Media",
    "price": 15.99,
    "category_id": 1,
    "created_at": "2019-06-28 00:21:02",
    "updated_at": "2019-06-28 00:21:02",
    "flavor": [
      {
	"id": 1,
	"name": "mussarela",
	"category_id": 1,
	"created_at": "2019-06-27 19:37:22",
	"updated_at": "2019-06-27 19:37:22"
      },
      {
	"id": 2,
	"name": "napolitana",
	"category_id": 1,
	"created_at": "2019-06-27 20:37:35",
	"updated_at": "2019-06-27 20:37:39"
      },
      {
	"id": 3,
	"name": "portuguesa",
	"category_id": 1,
	"created_at": "2019-06-27 20:37:50",
	"updated_at": "2019-06-27 21:37:50"
      }
    ],
    "category": {
      "id": 1,
      "name": "Pizza",
      "created_at": "2019-06-27 18:31:00",
      "updated_at": "2019-06-27 18:31:00"
    }
  },
  {
    "id": 4,
    "name": "Coca Cola 2L",
    "price": 9.99,
    "category_id": 2,
    "created_at": "2019-06-28 00:23:37",
    "updated_at": "2019-06-28 00:23:37",
    "flavor": [],
    "category": {
      "id": 2,
      "name": "Bebida",
      "created_at": "2019-06-28 00:22:16",
      "updated_at": "2019-06-28 00:22:16"
    }
  }
]

GET /product/id

Response:

{
  "id": 2,
  "name": "Pizza Media",
  "price": 15.99,
  "category_id": 1,
  "created_at": "2019-06-28 00:21:02",
  "updated_at": "2019-06-28 00:21:02",
  "category": {
    "id": 1,
    "name": "Pizza",
    "created_at": "2019-06-27 18:31:00",
    "updated_at": "2019-06-27 18:31:00"
  },
  "flavor": [
    {
      "id": 1,
      "name": "mussarela",
      "category_id": 1,
      "created_at": "2019-06-27 19:37:22",
      "updated_at": "2019-06-27 19:37:22"
    },
    {
      "id": 2,
      "name": "napolitana",
      "category_id": 1,
      "created_at": "2019-06-27 20:37:35",
      "updated_at": "2019-06-27 20:37:39"
    },
    {
      "id": 3,
      "name": "portuguesa",
      "category_id": 1,
      "created_at": "2019-06-27 20:37:50",
      "updated_at": "2019-06-27 21:37:50"
    }
  ]
}

PUT /product/id

Response:

{  
   "price":29.99
}

DELETE /product/id

Response:

status code 200

/flavor

POST /flavor

Request:

{  
   "name":"mussarela",
   "category_id":1
}

GET /flavor

Response:

[
  {
    "id": 1,
    "name": "mussarela",
    "category_id": 1,
    "created_at": "2019-06-27 19:37:22",
    "updated_at": "2019-06-27 19:37:22"
  },
  {
    "id": 2,
    "name": "napolitana",
    "category_id": 1,
    "created_at": "2019-06-27 20:37:35",
    "updated_at": "2019-06-27 20:37:39"
  },
  {
    "id": 3,
    "name": "portuguesa",
    "category_id": 1,
    "created_at": "2019-06-27 20:37:50",
    "updated_at": "2019-06-27 21:37:50"
  }
]

GET /flavor/id

Response:

{
  "id": 2,
  "name": "napolitana",
  "category_id": 1,
  "created_at": "2019-06-27 20:37:35",
  "updated_at": "2019-06-27 20:37:39"
}

PUT /flavor/id

Response:

{  
   "name":"mussarela ouro"
}

DELETE /flavor/id

Response:

status code 200

/client

POST /client

Request:

 {  
   "name":"Anthony Edward Stark Jr.",
   "telephone":31994726273
}

GET /client

Response:

[
  {
    "telephone": 31994726273,
    "name": "Anthony Edward Stark Jr.",
    "created_at": "2019-06-28 01:33:13",
    "updated_at": "2019-06-28 01:33:13"
  },
  {
    "telephone": 99314726273,
    "name": "Wade Winston Wilson",
    "created_at": "2019-06-28 01:36:11",
    "updated_at": "2019-06-28 01:36:11"
  }
]

GET /client/telephone

Response:

{
  "telephone": 31994726273,
  "name": "Anthony Edward Stark Jr.",
  "created_at": "2019-06-28 01:33:13",
  "updated_at": "2019-06-28 01:33:13"
}

PUT /client/telephone

Response:

{  
   "name":"Tony Stark"
}

DELETE /client/telephone

Response:

status code 200

/order

POST /order

Request:

 {  
   "client_telephone":"99314726273",
   "addresses":"10880, Malibu Point, 90265, Malibu , LA , Califórnia",
   "items":[  
      {  
	 "product_id":1,
	 "quantity":1,
	 "flavors_id":1
      },
      {  
	 "product_id":1,
	 "quantity":1,
	 "flavors_id":3
      },
      {  
	 "product_id":4,
	 "quantity":1
      }
   ]
}

GET /order

Response:

[	 
  {
    "id": 1,
    "client_telephone": 31994726273,
    "addresses": "10880, Malibu Point, 90265, Malibu , LA , Califórnia",
    "total_price": 30,
    "created_at": "2019-06-28 02:05:27",
    "updated_at": "2019-06-28 02:05:27"
  },
  {
    "id": 2,
    "client_telephone": 99314726273,
    "addresses": "200 Park Avenue, Manhattan , NY,
    "total_price": 40,
    "created_at": "2019-06-28 02:09:27",
    "updated_at": "2019-06-28 02:09:27"
  },
]

GET /order/id

Response:

{
  "order_id": 1,
  "client_id": 99314726273,
  "total_price": 30,
  "items": [
    {
      "name": "Pizza Grande",
      "flavor": "mussarela",
      "price": 10,
      "quantity": 1
    },
    {
      "name": "Pizza Grande",
      "flavor": "portuguesa",
      "price": 10,
      "quantity": 1
    },
    {
      "name": "Coca Cola 2L",
      "flavor": null,
      "price": 10,
      "quantity": 1
    }
  ]
}

DELETE /order/id

Response:

status code 200

pizzavel's People

Contributors

matheus-ac avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.