This repository contains the Laravel API Invoice project for the technical test. It provides CRUD operations for customers and products, as well as the ability to create and update invoices. Additionally, it supports retrieving all invoices and retrieving invoices by their unique code.
- CRUD operations for customers
- CRUD operations for products
- Create and update invoices
- Retrieve all invoices
- Retrieve invoices by code
- PHP 7.4 or higher
- Composer
- Laravel framework
- MySQL 5.7 (database)
- Clone the repository:
git clone https://github.com/siskastev/api-invoice.git- Navigate to the project directory:
cd api-invoice- Rename .env.example to .env
- Generate the application key:
php artisan key:generate- Install the dependencies:
composer install- Navigate to the migrations and seed the database:
php artisan migrate --seed- Start the development server:
php artisan servePOST /api/register: Create a new register user.
POST /api/login: Login user.
GET /api/profile: Profile user.
POST /api/logout: Logout user.
GET /api/customers: Retrieve all customers.GET /api/customers/{id}: Retrieve a specific customer by ID.POST /api/customers: Create a new customer.PUT /api/customers/{id}: Update an existing customer.DELETE /api/customers/{id}: Delete a customer.
GET /api/products: Retrieve all products.GET /api/products/{id}: Retrieve a specific customer by ID.POST /api/products: Create a new product(Admin role required).PUT /api/products/{id}: Update an existing product(Admin role required).DELETE /api/products/{id}: Delete a product (Admin role required).
GET /api/invoice: Retrieve all invoice.GET /api/invoice/{code}: Retrieve a specific invoice by code.POST /api/invoice: Create a new invoice.PUT /api/invoice/{code}: Update an existing invoice.DELETE /api/invoice/{code}: Delete a invoice.
A Postman collection API-INVOICE-LARAVEL.postman_collection.json and env for token laravel-api-invoice.postman_environment is provided in this project. You can import the collection into Postman to quickly test the API endpoints. The collection includes pre-configured requests for each endpoint, allowing you to easily interact with the API and view the responses.
The API uses Laravel Sanctum for API token authentication. To authenticate requests, include the API token in the request headers:
Authorization: Bearer {api_token}. To log in as the admin user, use the following credentials:
Email: admin@gmail.comPassword: admin