Task: Build a Mini Inventory Management API
Goal: To assess your ability to design an API, handle business logic, and integrate from frontend.
Create a simple Product Management API with endpoints:
POST /api/products→ Create a product (fields:name,price,stock)GET /api/products→ Get list of productsPUT /api/products/{id}→ Update product stock or priceDELETE /api/products/{id}→ Delete a productGET /api/products/low-stock→ Return products with stock less than 5
- Validate all requests (no empty names, price > 0, stock ≥ 0).
- Return JSON responses with laravel resources/collection and/or consistent structure (
data,message,status). - Add authentication using Laravel Sanctum (optional if time permits).
- Add a global exception handler.
- Implement resource routes and controllers.
- Write a query scope
lowStock()in Product model.