This project was built on Laravel 9, PHP 8.1, Bootstrap 5
composer require laravel/ui
php artisan ui bootstrap
npm install && npm run dev
- Publisher
- Author
- Book
-
publishers
- id
- title (string, 255)
- timestamps
-
authors
- id
- name (string, 255)
- timestamps
-
books
- id
- title (string, 255)
- timestamps
- Many-To-Many 'books' with 'publishers' (table 'book_publisher')
- Many-To-Many 'authors' with 'books' (table 'author_book')
Tou can seed fields made by faker in database with this command
php artisan migrate --seed
- Get list of books with authors and publishers
GET /api/books
{
"id" : int,
"title" : string,
"created_at" : timestamp,
"updated_at" : timestamp,
"publishers" : [
{
"id" : int,
"title" : string,
"created_at" : timestamp,
"updated_at" : timestamp,
"pivot": {
"book_id" : int,
"publisher_id" : int
}
},
...
],
"authors": [
{
"id" : int,
"name" : string,
"created_at" : timestamp,
"updated_at" : timestamp,
"pivot": {
"book_id" : int,
"author_id" : int
}
},
...
]
}
- Create new book
POST /api/books
Parameter | Type | Description |
---|---|---|
title |
string |
Required. Book title. Must be unique |
publisher_id |
int |
Required. Publisher ID. Must be exists in table 'publishers' |
authors |
array |
Required. Authors ID. Each element of array must exists in table 'authors' |
- Update book
PUT /api/books/{book_id}
Parameter | Type | Description |
---|---|---|
book_id |
int |
Required. Book ID |
title |
string |
Book title. Must be unique |
authors |
array |
Authors ID. Each element of array must exists in table 'publishers'. All existed values will be replaced with new |
- Delete book
DELETE /api/books/{book_id}
Parameter | Type | Description |
---|---|---|
book_id |
int |
Required. Book ID |