PHPackages                             threeleaf/biblioteca - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. threeleaf/biblioteca

ActiveLibrary[Database &amp; ORM](/categories/database)

threeleaf/biblioteca
====================

A Laravel Eloquent Model for managing a library of books.

2.0.0(4mo ago)0551GPL-3.0+PHPPHP &gt;=8.2CI passing

Since Dec 27Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/ThreeLeaf-com/Biblioteca)[ Packagist](https://packagist.org/packages/threeleaf/biblioteca)[ RSS](/packages/threeleaf-biblioteca/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (4)Used By (0)

Biblioteca Model Library
========================

[](#biblioteca-model-library)

**Biblioteca Model** is a Laravel-based library designed to provide a comprehensive model framework to organize and manage data related to many kinds of written material, with a specific focus on books. This library allows you to structure and manage complex data, including authors, books, chapters, paragraphs, sentences, notes, and more.

[![Latest Stable Version](https://camo.githubusercontent.com/639fbf7b87f693b4bb3b3f5198f408139a142088afcd2b3dc6de288aec7a5192/68747470733a2f2f706f7365722e707567782e6f72672f74687265656c6561662f6269626c696f746563612f762f737461626c65)](https://packagist.org/packages/threeleaf/biblioteca)[![GitHub last commit](https://camo.githubusercontent.com/3a886b89f48d532387c35722ebd1989345fd9550b8c173e24aad50dde82de5ed/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f54687265654c6561662d636f6d2f4269626c696f74656361)](https://github.com/ThreeLeaf-com/Biblioteca/commits/main)[![Build Status](https://github.com/ThreeLeaf-com/Biblioteca/actions/workflows/tests.yaml/badge.svg?branch=main)](https://github.com/ThreeLeaf-com/Biblioteca/actions)[![Coverage](./public/images/coverage-badge.svg)](./public/images/coverage-badge.svg)[![PHP Version](https://camo.githubusercontent.com/bf64120140e1ed7e92eeff06ecd71c971ef855fd490e578977bf5ad4e6295842/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f74687265656c6561662f6269626c696f74656361)](https://packagist.org/packages/threeleaf/biblioteca)[![License](https://camo.githubusercontent.com/5473e6dde652a7347a4b8740cd532236b885c9dddcc2468a5608e9637fd97687/68747470733a2f2f706f7365722e707567782e6f72672f74687265656c6561662f6269626c696f746563612f6c6963656e7365)](https://packagist.org/packages/threeleaf/biblioteca)[![Total Downloads](https://camo.githubusercontent.com/ab3f502ee2fa6115f4ec293c88787df0ae8a4c185ee31cd1df160c26c8479978/68747470733a2f2f706f7365722e707567782e6f72672f74687265656c6561662f6269626c696f746563612f646f776e6c6f616473)](https://packagist.org/packages/threeleaf/biblioteca)

Features
--------

[](#features)

- **Organize Complex Written Materials**: Manage data models for books, chapters, paragraphs, sentences, notes, and much more.
- **Multi-level Data Organization**: Supports nested structures, such as books containing chapters, chapters containing paragraphs, and so on.
- **Supports CRUD Operations**: Easily create, read, update, and delete entities such as books, authors, and notes.
- **Relational Data Management**: Models are related in a structured way, allowing you to retrieve associated data, such as the author of a book or the chapters in a book.
- **OpenAPI Documentation Integration**: Prepares your data models for API usage with comprehensive OpenAPI (Swagger) annotations.

Models Included
---------------

[](#models-included)

The Biblioteca Model library includes the following data models:

- **Author**: Represents the author of a book.
- **Book**: Represents a book, which can have multiple chapters, tags, genres, etc.
- **Chapter**: Represents a chapter in a book, containing paragraphs.
- **Paragraph**: Represents a paragraph in a chapter, containing sentences.
- **Sentence**: Represents a sentence in a paragraph.
- **Note**: Represents additional notes or annotations related to sentences.
- **Figure**: Represents a figure associated with a chapter.
- **Index**: Represents an index entry for a book, linking to a page or section.
- **Tag**: Represents tags associated with books for categorization.
- **Genre**: Represents a genre, which can be associated with multiple books.
- **Series**: Represents a series of books, linking to an author and the individual books in the series.
- **Table of Contents (ToC)**: Represents a table of contents entry for a book, linking chapters and page numbers.

Requirements
------------

[](#requirements)

- **PHP**: &gt;=8.2
- **Laravel**: ^12.0

Installation
------------

[](#installation)

1. Install the package via Composer:

    ```
    composer require threeleaf/biblioteca
    ```

    **Note**: Version 2.0.0+ requires Laravel 12. For Laravel 10 compatibility, use version ^1.0.
2. Publish the package configuration:

    ```
    php artisan vendor:publish --provider="ThreeLeaf\Biblioteca\BibliotecaServiceProvider"
    ```
3. Run migrations to create the necessary database tables:

    ```
    php artisan migrate
    ```

Usage
-----

[](#usage)

After installation and configuration, you can use the models provided by the Biblioteca library to manage written materials. Below are some examples of how you can use these models in your application.

### Example: Creating a New Book with an Author

[](#example-creating-a-new-book-with-an-author)

```
use ThreeLeaf\Biblioteca\Models\Author;
use ThreeLeaf\Biblioteca\Models\Book;

$author = Author::create([
    'first_name' => 'John',
    'last_name' => 'Marsh',
    'biography' => 'John Marsh is a prolific writer...',
]);

$book = Book::create([
    'title' => 'The Great Adventure',
    'author_id' => $author->author_id,
    'published_date' => now(),
    'summary' => 'A thrilling tale of adventure...',
]);

$bookAuthor = $book->author;
echo "Book Author: $bookAuthor->first_name $bookAuthor->last_name";
```

### Example: Adding Chapters and Paragraphs to a Book

[](#example-adding-chapters-and-paragraphs-to-a-book)

```
use ThreeLeaf\Biblioteca\Models\Chapter;
use ThreeLeaf\Biblioteca\Models\Paragraph;

$chapter = Chapter::create([
    'book_id' => $book->book_id,
    'chapter_number' => 1,
    'title' => 'Chapter 1: The Beginning',
]);

$paragraph = Paragraph::create([
    'chapter_id' => $chapter->chapter_id,
    'paragraph_number' => 1,
    'content' => 'This is the first paragraph of the chapter...',
]);
```

### Example: Querying Books by Author

[](#example-querying-books-by-author)

```
/* Retrieve all books by a specific author */
$booksByAuthor = Author::find($author->author_id)->books;

foreach ($booksByAuthor as $book) {
    echo $book->title;
}
```

API Integration
---------------

[](#api-integration)

If you want to expose the data through an API, the library is integrated with **l5-swagger**, making it easy to generate OpenAPI (Swagger) documentation. Use the provided controllers or create your own to work with the models in an API context.

### Example API Route for Authors

[](#example-api-route-for-authors)

Add the following route to `routes/api.php`:

```
use App\Http\Controllers\AuthorController;

Route::apiResource('authors', AuthorController::class);
```

Run the Swagger documentation generation command to create up-to-date documentation:

```
php artisan l5-swagger:generate
```

A complete example of the available API routes can be found in the Biblioteca project's [api.php](routes/api.php) file.

If you would like to use the Biblioteca project's [api.php](routes/api.php) file as-is, you can include the project API routes into your own project by adding the following line to your project's `api.php` file:

```
require base_path('vendor/threeleaf/biblioteca/routes/api.php');
```

Database Migrations
-------------------

[](#database-migrations)

After installing the library, run migrations to create all the necessary database tables for storing data related to books and other written material.

```
php artisan migrate
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please submit a pull request or open an issue to discuss your ideas.

License
-------

[](#license)

This library is open-sourced software licensed under the [GPL-3.0+](https://www.gnu.org/licenses/gpl-3.0.html).

Miscellaneous
-------------

[](#miscellaneous)

### OpenApi Documentation

[](#openapi-documentation)

OpenAPI documentation can be generated within the application using the command:

```
composer generate-swagger

```

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance75

Regular maintenance activity

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 69.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~370 days

Total

2

Last Release

137d ago

Major Versions

1.0.0 → 2.0.02026-01-01

PHP version history (2 changes)1.0.0PHP &gt;=8.1

2.0.0PHP &gt;=8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5519679?v=4)[John A. Marsh](/maintainers/JohnZavyn)[@JohnZavyn](https://github.com/JohnZavyn)

---

Top Contributors

[![JohnZavyn](https://avatars.githubusercontent.com/u/5519679?v=4)](https://github.com/JohnZavyn "JohnZavyn (34 commits)")[![john-marsh-redcat](https://avatars.githubusercontent.com/u/212599783?v=4)](https://github.com/john-marsh-redcat "john-marsh-redcat (15 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/threeleaf-biblioteca/health.svg)

```
[![Health](https://phpackages.com/badges/threeleaf-biblioteca/health.svg)](https://phpackages.com/packages/threeleaf-biblioteca)
```

###  Alternatives

[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k302.7k1](/packages/cybercog-laravel-love)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[genealabs/laravel-pivot-events

This package introduces new eloquent events for sync(), attach(), detach() or updateExistingPivot() methods on BelongsToMany relation.

1404.9M8](/packages/genealabs-laravel-pivot-events)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)[aglipanci/laravel-eloquent-case

Adds CASE statement support to Laravel Query Builder.

115157.2k](/packages/aglipanci-laravel-eloquent-case)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
