Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Eloquence Laravel Package

sofa/eloquence

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Feature Expansion for Search Functionality:

    • Enable full-text search across related models without complex custom queries (e.g., for e-commerce product catalogs, content management systems, or SaaS platforms with nested data).
    • Reduce reliance on external search engines (e.g., Algolia, Elasticsearch) for lightweight use cases where Eloquent’s native capabilities are insufficient.
    • Example: A blog platform needing to search posts and their associated tags/authors in a single query.
  • Validation at the Model Layer:

    • Shift validation logic from controllers/forms to models, improving reusability and reducing boilerplate (e.g., for APIs, admin panels, or form-heavy applications).
    • Enforce business rules (e.g., "price must be positive," "email must match domain") without duplicating code across services.
    • Example: A subscription service validating user input for billing cycles or tier upgrades.
  • Dynamic Attribute Handling:

    • Support meta fields (e.g., custom key-value pairs for CMS content, user profiles, or product variants) without schema migrations.
    • Implement attribute transformation (e.g., hashing passwords, formatting dates, or normalizing case) via declarative mutators.
    • Example: A real estate platform storing arbitrary property features (e.g., {"amenities": ["pool", "gym"]}) without rigid database columns.
  • Data Mapping for APIs/Integrations:

    • Standardize how models map to API responses, database fields, or third-party schemas (e.g., Stripe, Shopify) using Mappable.
    • Avoid manual array reshaping in controllers or serializers (e.g., Laravel’s Resource classes).
    • Example: A marketplace syncing listings to an external vendor platform with non-standard field requirements.
  • Roadmap: "Build vs. Buy" Trade-offs:

    • Buy: Use this package to avoid reinventing wheel for common Eloquent extensions (e.g., search, validation). Ideal for teams with limited backend resources.
    • Build: If requirements are highly specialized (e.g., real-time search, custom validation workflows), evaluate whether extending this package or writing bespoke solutions is better.
    • Example: A startup with a tight deadline might adopt Searchable to launch MVP search faster, then replace it later with Elasticsearch.
  • Use Cases:

    • Content Platforms: Search across articles, comments, and user profiles.
    • SaaS Applications: Validate user inputs for CRUD operations (e.g., invoices, settings).
    • E-commerce: Map product attributes to API schemas or third-party marketplaces.
    • Admin Panels: Add meta fields to models without migrations (e.g., "hidden" flags, custom labels).

When to Consider This Package

  • Adopt When:

    • Your Laravel app uses Eloquent ORM and needs search, validation, or dynamic attributes without heavyweight dependencies.
    • You want to reduce boilerplate (e.g., repetitive validation logic, manual search queries, or attribute transformations).
    • Your team lacks dedicated backend resources to build these features from scratch.
    • You’re working with nested/related data that requires flexible querying (e.g., "Find posts where title or any comment body matches ‘Laravel’").
    • You need meta fields but want to avoid NoSQL or complex schema changes.
  • Look Elsewhere When:

    • You require real-time search or advanced analytics (consider Elasticsearch, Algolia, or Meilisearch).
    • Your validation needs are highly complex (e.g., multi-step workflows, external API checks) beyond what Validable supports.
    • You’re using non-Laravel PHP frameworks (this package is Laravel-specific).
    • The package’s last release (2019) is a concern for long-term maintenance (evaluate fork risk or alternatives like Spatie’s packages).
    • You need high-performance bulk operations (this package is optimized for single-model queries).
    • Your use case requires graph traversals (consider Laravel Scout or custom GraphQL resolvers).

How to Pitch It (Stakeholders)

For Executives:

"This package lets us add powerful features to our Laravel app with minimal dev effort—think search across related data, automatic input validation, and flexible model attributes—without hiring extra engineers or integrating complex tools. For example, we could launch a search feature for our blog in days instead of weeks, using Eloquent’s built-in capabilities. It’s like adding a ‘turbo mode’ to our existing database queries, reducing technical debt while keeping costs low. The MIT license means no hidden risks, and the community adoption (1K+ stars) signals reliability."

Ask:

  • "Would you prioritize accelerating feature delivery (e.g., search, validation) over building custom solutions?"
  • "Are there any compliance or scalability concerns with using a package last updated in 2019?"

For Engineers:

*"Sofa/Eloquence gives us five battle-tested extensions for Eloquent that solve common pain points:

  1. Searchable: Full-text search across models and their relations (e.g., Post::search('laravel')->with('comments')).
  2. Validable: Move validation logic to models (e.g., @Validable(['email', 'password'])) to DRY up controllers.
  3. Mappable: Standardize how models serialize to APIs/database (e.g., hide internal fields, rename attributes).
  4. Metable: Add dynamic key-value pairs to any model without migrations (e.g., User::meta('preferences')).
  5. Mutable: Clean attribute transformations (e.g., auto-hash passwords, format dates) with minimal setup.

Why use it?

  • Faster development: No need to write custom queries or validators.
  • Consistency: Enforce rules at the model layer, not per route/controller.
  • Flexibility: Works with existing Eloquent; no ORM lock-in.

Trade-offs:

  • Last updated in 2019 (but core Eloquent features are stable).
  • Not for high-scale bulk operations (focuses on single-model queries).

Proposal: Let’s dogfood this for our [X feature] (e.g., search, user profiles) and compare it to alternatives like Spatie’s packages or custom code. If it meets our needs, we can adopt it incrementally (e.g., start with Searchable and Validable)."*

Ask:

  • "What’s our biggest pain point with Eloquent right now? Could this package address it?"
  • "Should we evaluate modern alternatives (e.g., Spatie, Laravel Nova packages) or proceed with this?"
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
daikazu/eloquent-salesforce-objects
unseen-codes/chat
romalytar/yammi-jobs-monitoring-laravel
kisame76/filament-db-table-state
nqxcode/laravel-lucene-search
dpfx/laravel-livewire-wizards
workos/workos-php-laravel
sofa/laravel-global-scope
nawasara/auth-primitives
adhocrat-io/arkhe-main
make-dev/orca-harpoon
itsemon245/lamet
baks-dev/dashboard
amoifr/pickle-panther-bundle
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle