Skip to content

Michaeltlee/code-test

 
 

Repository files navigation

Requirements

  • 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

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.

Users

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

ProductUser Pivot

product_user

  • id
  • user_id
  • product_id

Products

Each product must have, but is not limited to:

  • ID
  • Name
  • Description
  • Price
  • Image

Database

  • 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.

Authentication

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.

Requests

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

UI

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

Completion

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 89.7%
  • PHP 5.9%
  • Vue 2.1%
  • CSS 1.4%
  • Other 0.9%