- You have up to 48 hours to submit
- Create a simple RESTful API written in Laravel (latest version)
- All responses should be JSON
- All requests should be JSON
- Simple UI Interface implemented in a JS Framework (plus if Vue)
The exercise consists of users, subscriptions and products. A user will have the ability to add & remove products within their account. A user must have an active subscription to add a product to their account.
Each user must have, but is not limited to:
- ID
- First Name
- Last Name
- Email (unique)
Please note:
- These users are the only users that are able to make requests via the API.
- User creation/maintenance is not done through the API (see Database section below).
- Users can own many products
product_user
- id
- user_id
- product_id
Each product must have, but is not limited to:
- ID
- Name
- Description
- Price
- Image
- MySQL
- All tables in the database must be created programmatically
- The user table should be seeded with at least five users
- Run
php artisan db:seed
to seed the database with 10 users.
- Run
You must implement an authentication system so that the API knows which of the users is making the request.
- All requests should ensure that an authorized user is making the request. In the event of an unauthorized user, an error should be thrown.
The following requests should be implemented:
- Add product
- All fields required except ID and image
- Update product
- All fields required except image
- Delete product
- Get product
- Upload product image
- Get list of all products
- Attach a product to requesting user
- User must have an active subscription
- Remove product from requesting user
- List products attached to requesting user
Description | Route | Method | Notes |
---|---|---|---|
Add product | /api/product |
POST | All fields required except ID and image |
Update product | /api/products/{product} |
PUT | All fields required except image |
Delete product | /api/products/{product} |
DELETE | |
Get product | /api/products/{product} |
GET | |
Upload product image | /api/products/{product}/image |
POST | |
Get list of all products | /api/products |
GET | |
Attach product to requesting user | /api/users/products/{product} |
POST | |
Remove product from requesting user | /api/users/products/{product} |
DELETE | |
List products attached to requesting user | /api/users/products |
GET |
Create a simple ui interface, written in your favorite JS Framework (Preferred: VueJS) for a user to
- View all available products
*Bonus
- Authenticate
- Add/Remove products
- Writing tests (both backend and frontend) to backup your code is a huge plus
- Writing tests for backend
- Writing tests for frontend
- How to setup the local site
php artisan serve
- 127.0.0.1:8000/products
- Instructions on how to create and seed database tables
- https://laravel.com/docs/9.x/database#sqlite-configuration
-
php artisan migrate
-
php artisan db:seed
- Compile assets (if any)
-
composer install && npm install
-