Your task is to refactor the GetProductsController
without altering its existing functionality, fixing any bugs that you may find. We are looking to see your understanding and use of the Laravel ecosystem as well as adopting the latest PHP fundamentals and best practices. You are free to use any methodologies or packages as deemed fit for this task.
We have an existing API route, /api/products
, which returns all products. This functionality should remain unchanged.
Please create a new API route /api/products/{section}
, which will return all products belonging to a specified section.
The models and their relationships have already been established.
Set up your dev environment using the setup that you are most comfortable with. The project already includes Laravel Sail for your convenience.
Test data is provided through seeders. After running the php artisan migrate --seed
command, your database should be ready for use.
While we understand the time-consuming nature of coding tasks, we kindly request that you limit yourself to a maximum of one to two hours on this task. Please do not worry if you can't complete the task within the stipulated time. Our primary interest is in assessing your problem-solving approach and your understanding of the Laravel framework and best practices, not necessarily the end product. Any notes about your strategies for tackling this task, or your thoughts on potential improvements to the code, are greatly appreciated.
The easiest way for all involved to review this test is via GitHub. We request that you Fork this project and then perform the "task" on your fork as a private repository. Once completed please privide access to your fork to @albanh, @alexbirtwell and @oddvalue. This can be done under Settings > Collaborators.
Any notes on your strategy or improvements should be added to the repository in a NOTES.md or replace the content of this readme.