This is my take at the simplo-sro/job-php-programmer task. The original assignment is:
Create a simple Laravel application that would serve as an API. The application will be used to manage customers. The proposed API should meet all REST principles and use JSON for data exchange.
Do not use any third party packages.
Application will consist of following entities:
A particular customer. For this entity, create end-points for CRUD operations according to the REST convention. Choose whatever attributes you like.
A customer group. Customer can belong to 0 - N customer groups. You do not need to create a separate resource for this entity. Preparing the data before hand is enough, for example using a seed.
- Find a suitable way to create a relation between a customer and a customer group (POST/PUT on the user resource).
- Find a suitable way to optionally request customer's customer groups data along with the user (GET on the user resource).
- Inputs must be validated. Use PORTO architecture (and Repository Pattern, optionally) for bonus points.
-
Clone this repository:
git clone https://github.com/OndrejBakan/job-php-programmer.git -
Switch to the project folder:
cd job-php-programmer -
Install dependencies using composer:
composer install -
Copy .env file:
cp .env.example .env -
Change these lines to use SQLite for quickstart:
DB_CONNECTION=sqlite DB_HOST=127.0.0.1 DB_PORT=3306 # DB_DATABASE=./database/database.sqlite DB_USERNAME=root DB_PASSWORD= -
Generate application key:
php artisan key:generate -
Run database migrations:
php artisan migrate -
Run database seeders:
php artisan db:seed -
Start the local development server:
php artisan serve
- laravel/framework
- laravel/pint
- Debugbar for Laravel