Recruitment task implemented as a Laravel REST API for managing books and browsing authors.
This README is the source of truth for the application behavior.
All /api/books endpoints require Sanctum authentication.
GET /api/books- paginated list of books with eager-loaded authorsGET /api/books/{id}- single book with authorsPOST /api/books- create a bookPUT /api/books/{id}- update a bookDELETE /api/books/{id}- delete a book
All /api/authors endpoints are public and read-only.
GET /api/authors- paginated list of authors with eager-loaded booksGET /api/authors/{id}- single author with booksGET /api/authors?search=title- filter authors by related book title
Write operations for authors are intentionally not exposed over HTTP.
authors.last_book_titlestores the title of the most recently attached book for a given author- the value is refreshed asynchronously after book create, update, and delete operations
- Laravel 12, PHP 8.3+
- many-to-many
authors <-> booksrelationship - FormRequest validation for book writes
- Sanctum-protected book endpoints
- public, read-only author endpoints
- search by related book title using
whereHas - queue job that refreshes
last_book_title - feature test suite
- GitHub Actions CI workflow
- Artisan command:
php artisan app:create-author
- PHP 8.3+
- Composer
- SQLite 3 (default) or MySQL 8.0+
This project is API-only. Node.js is not required to install, run, or test the API.
git clone https://github.com/przemekp95/library-api.git
cd library-api
composer setup
php artisan serveManual setup is also available if you prefer:
composer install
cp .env.example .env
touch database/database.sqlite
php artisan key:generate
php artisan migrate --seedUse a Sanctum personal access token for /api/books requests:
- Create a user.
- Generate a personal access token.
- Send
Authorization: Bearer {token}.
php artisan test
composer auditMIT