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

Laravel Computed Attributes Laravel Package

korridor/laravel-computed-attributes

Adds “computed attributes” to Laravel models, letting you define dynamic/derived properties that behave like normal attributes (including access/casting/serialization) without storing them in the database. Useful for clean model APIs and reusable calculations.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Derived Data Persistence: Eliminates the need for manual database triggers or application-level caching for computed fields (e.g., order_total, user_engagement_score), reducing backend complexity and improving data consistency.
  • Roadmap Efficiency: Accelerates feature delivery for teams building analytics dashboards, pricing engines, or dynamic UI elements (e.g., "You saved $X with this discount").
  • Build vs. Buy: Avoids reinventing computed attribute logic (e.g., caching, recalculation triggers) while maintaining Laravel’s Eloquent ecosystem. New: Laravel 13 support ensures alignment with modern Laravel development.
  • Use Cases:
    • E-commerce: Dynamic pricing tiers, tax calculations, or loyalty points.
    • SaaS Analytics: Pre-computed metrics (e.g., "customer_lifetime_value") for reporting.
    • Data Migration: Backfill derived fields without downtime.
    • Modern Laravel Apps: Ideal for teams adopting Laravel 13, as this package now guarantees compatibility and includes PHPStan for code quality.

When to Consider This Package

  • Adopt if:
    • Your application requires persistent computed fields (e.g., financial calculations, aggregations) that must stay in sync with source data.
    • You need to reduce query load by caching derived values in the database.
    • Your team uses Laravel 13 and wants a declarative solution over raw SQL triggers or custom logic.
    • You prioritize code quality and want static analysis (PHPStan) in your CI pipeline.
    • You’re building features that rely on real-time derived data (e.g., dynamic UI elements, reporting).
  • Look elsewhere if:
    • Computed fields are transient (use Eloquent accessors/mutators instead).
    • Your data model requires complex event-driven recalculations (e.g., event sourcing, CQRS).
    • You’re constrained by strict database schemas (e.g., read-only replicas, no-writes allowed).
    • You’re not using Laravel 13 (though backward compatibility exists; verify for your version).

How to Pitch It (Stakeholders)

For Executives: "This package lets us store derived data (e.g., dynamic pricing, user metrics) directly in the database—cutting query load, speeding up feature delivery, and reducing backend complexity. Now fully supports Laravel 13, with built-in static code analysis (PHPStan) to improve code quality. It’s like ‘smart caching’ for Eloquent models, ensuring consistency while eliminating recalculation overhead. Perfect for scaling features like analytics dashboards or pricing engines without adding technical debt."

For Engineering: *"This package turns Eloquent accessors into persistent computed fields (e.g., order_total = subtotal + tax). Now officially supports Laravel 13 and includes PHPStan in CI for stricter code quality. Saves us from writing manual sync jobs or triggers. Key benefits:

  • Auto-persists computed values to the DB on save.
  • Caching control (disable for volatile data).
  • Seamless integration with Eloquent (events, observers, etc.).
  • MIT-licensed, actively maintained, and updated dependencies (GitHub Actions, etc.). Tradeoff: Adds a tiny DB column per computed field, but eliminates recalculation overhead. Ideal for performance-critical reads or offline-first apps."*
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.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope