Skip to content

jcortesa/laravel-store-rest-api

Repository files navigation

laravel-store-rest-api

Introduction

This repository contains a REST API built with Laravel, designed to manage a collection of stores and products. The API allows users to perform CRUD operations on stores and products, including creating, reading, updating, and deleting data.

You can find me on:

Requirements

  • Docker Desktop
  • Composer v2.0 or higher

Installation

Clone repository:

git clone https://github.com/jcortesa/laravel-store-rest-api
cd laravel-store-rest-api

Create a .env file by copying the example file:

cp .env.example .env

Install dependencies and start the application using Laravel Sail:

composer install
./vendor/bin/sail up -d

In browser, navigate to http://localhost to access the API.

API Endpoints

The API provides the following endpoints:

  • POST /api/stores: Create a new store. Pass a collection of products in the request body to associate them with the store.
  • GET /api/stores: Retrieve a list of all stores.
  • GET /api/stores/{id}: Retrieve a specific store by ID.
  • PUT /api/stores/{id}: Update an existing store by ID.
  • DELETE /api/stores/{id}: Delete a store by ID.
  • PUT /api/stores/{storeId}/products/{productId}/sell: Sell a product from a store. This endpoint will update the stock of the product and return the updated product details.

See specification on docs/api.yaml. Test it also with docs/api.http using HTTP Client by JetBrains.

Testing

To run the tests, use the following command:

./vendor/bin/sail artisan test

Code static analysis

Making use of PHPStan to analyze the code quality, run the following command:

./vendor/bin/sail bin phpstan analyze

License

This project is licensed under the MIT License. See the LICENSE file for details

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages