composer create-project --prefer-dist laravel/laravel TechnicalTest
php artisan make:model -cfm People
I have decided to have one table as I know that the job_role could go to a separate table. For this certain test which have the maximum of 10 records with a condition to not allow more than 4 records to have same job_role, the relationship will complicate the task and we will need to add more logic to enforce our condition. Even though it could be done by adding counter to job_role table to show how many persons do we have in this certain role, but updating the counter would be a bit annoying. With this solution we can easily count our condition with a simple query.
php artisan db:seed
- clone it from github.
- create a database called TechnicalTest [it is in .env.example file].
- configure your database connection [.env file]
- run following commands in project folder:
- composer install
- php artisan migrate
- php artisan db:seed [seeding with markup form provided for this test, you should run it only once]
- php artisan config:cache
- php artisan route:cache [just in case it is not working fine]
- visit [url/people] and play with it...
It is pushed to the root folder of the project...
4 Hours of Quality work :-)