Backend Assignment

Task

You were given a sample Laravel project which implements sort of a personal wishlist where user can add their wanted products with some basic information (price, link etc.) and view the list.

Refactoring

The ItemController is messy. Please use your best judgement to improve the code. Your task is to identify the imperfect areas and improve them whilst keeping the backwards compatibility.

New feature

Please modify the project to add statistics for the wishlist items. Statistics should include:

  • total items count
  • average price of an item
  • the website with the highest total price of its items
  • total price of items added this month

The statistics should be exposed using an API endpoint. Moreover, user should be able to display the statistics using a CLI command.

Please also include a way for the command to display a single information from the statistics, for example just the average price. You can add a command parameter/option to specify which statistic should be displayed.

Open questions

Please write your answers to following questions.

Please briefly explain your implementation of the new feature

...

For the refactoring, would you change something else if you had more time?

...

Running the project

This project requires a database to run. For the server part, you can use php artisan serve or whatever you're most comfortable with.

You can use the attached DB seeder to get data to work with.

Running tests

The attached test suite can be run using php artisan test command.