Choose to create a Lumen project based on simple requirements. If this wasn't a demo I would have choosen the Laravel Framework so I have more features state e.g. sessions.
Completed using migrations however I would have made a few changes if I had the chance as the diagrams vs spreadsheets didn't match exactly.
$router->post('products', [ 'uses' => 'ProductController@store']);
$router->put('products/{id}', [ 'uses' => 'ProductController@update']);
$router->delete('products/{id}', [ 'uses' => 'ProductController@destroy']);
$router->get('products/{id}/addstock', [ 'uses' => 'ProductController@addStock']);
$router->get('products', [ 'uses' => 'ProductController@index']);
$router->get('products/{id}', [ 'uses' => 'ProductController@show']);
3.4. Able to pass optional stock parameter in get products and product details API to get stock onHand summary.
You can use the following GET params to get additional data.
- ?withStock=1
- ?page=1
You can use the following GET param to sort.
- ?sortByStock=DESC
You can use the following GET params to get availability.
- ?available=1
I wasn't sure how exqactly you wanted this built but for demo purposes I made a simple form where users can choose a type e.g. propducts/stocks and upload their CSV for bulk updates/inserts.
There's many ways to improve performance here if required such as push data straight to a queue/job.
You could also just use an API but would need to becareful about not hitting the max_input_vars
limit.
When you upload a CSV in this demo products can be either created or updated from the same CSV. Stocks however is just simply create only.
Ideally I would have returned nice error responses but Lumen doesn't support returning state so for now json is being returned.
Same as above.
Note I did notice some data issues in the CSV - mostly around product ID's/Codes not actually existing. In this demo if the product doesn't exist that record is ignored on import.