A Laravel package extending Eloquent with camel-cased attributes, count/sum caching, sluggable models, and readonly protection.
Eloquence is a Laravel package that extends the Eloquent ORM with additional database utilities and behaviors. It solves common development needs like automatic camel-casing of attributes, caching aggregated values (counts and sums), generating slugs, and protecting models as readonly. It integrates seamlessly as a drop-in library without altering core Laravel functionality.
Laravel developers building applications that require enhanced Eloquent model capabilities, such as consistent coding styles, performance optimizations via caching, or data integrity through readonly models.
Developers choose Eloquence for its focused, non-intrusive enhancements to Eloquent, offering features like count/sum caching for performance, camel-casing for API consistency, and behaviors that respect domain-specific relationships—all without modifying Laravel's core.
A drop-in library for certain database functionality in Laravel, that allows for extra features that may never make it into the main project.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Automatically transforms snake_case database columns to camelCase for attribute access and JSON responses, ensuring a unified coding style without altering schema migrations, as highlighted in the CamelCased traits section.
Provides count and sum caching to reduce database queries for aggregated values, such as caching post counts per author, which improves efficiency for ordering and filtering operations.
Allows models to be marked as readonly using the HasReadOnly trait, preventing accidental writes and ensuring data protection across domain boundaries without additional configuration.
Leverages PHP 8.1 attributes for behavior configuration, offering a clean, declarative way to set up caches and other features directly on relationship methods, as seen in the CountedBy and SummedBy examples.
Version 11 is a complete rebuild with non-backwards-compatible changes, requiring significant code updates for upgrades, such as renaming traits and migrating cache configurations to attributes.
The cache system strongly recommends wrapping model saves in database transactions to prevent inconsistency, adding complexity and potential points of failure if transactions are not properly managed, as warned in the cache recommendations.
Requires PHP 8.1 or higher for attribute support and is tightly coupled with Laravel's Eloquent ORM, excluding projects with older PHP versions or alternative database abstractions.