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 Lift Laravel Package

wendelladriel/laravel-lift

Experimental Laravel package that supercharges Eloquent models with typed public properties matching your schema, powered by PHP 8 attributes. Add validation rules and other metadata directly on models and access them via handy methods, using Eloquent events for easy drop-in use.

View on GitHub
Deep Wiki
Context7

Getting Started

  1. Install the package via Composer:

    composer require wendelladriel/laravel-lift
    
  2. Start with a basic Eloquent model — add #[Property] attributes to declare public properties that mirror your database columns. For example:

    use WendellAdriel\Lift\Attributes\Property;
    
    #[Property]
    class User extends Model
    {
        // No manual $fillable, $casts, or property declarations needed!
    }
    

    Lift will auto-generate public properties (e.g., public string $name), infer types from column definitions, and handle casts automatically — all visible to your IDE.

  3. First use case: rapid model scaffolding with validation & rules embedded

    use WendellAdriel\Lift\Attributes\Property;
    use WendellAdriel\Lift\Attributes\CreateRules;
    use WendellAdriel\Lift\Attributes\UpdateRules;
    
    #[Property]
    #[CreateRules(['email' => 'required|email|unique:users,email'])]
    #[UpdateRules(['email' => 'required|email|unique:users,email,' . $this->id])]
    class User extends Model {}
    

    Rules appear inline, IDE shows them on model usage, and you avoid separate form request boilerplate.


Implementation Patterns

  • Model-first development with IDE support

    • Write #[Property] and let Lift generate typed, discoverable properties.
    • Access properties directly (e.g., $user->name) without IDE warnings.
  • Inline validation alongside model logic

    • Use #[CreateRules], #[UpdateRules], #[Rules] (for generic rules).
    • Combine with #[Cast] for custom casters (including enums):
      #[Property]
      #[Cast(\App\Casts\StatusCast::class)]
      #[Cast(enum: Status::class)] // enum support since v0.15
      public Status $status;
      
  • Relationships via attributes

    • Declare relations inline with #[BelongsTo], #[HasMany], etc., including custom class names and key names:
      #[BelongsTo(User::class, 'author_id', 'id')]
      public User $author;
      
  • Event listeners embedded in models

    • Use #[Listener('created')], #[Listener('deleted')] to hook into Eloquent events without separate observers.
  • Lift migrations for schema-first work

    • Run php artisan lift:migration to scaffold a migration based on existing model attributes (#[Property], #[Cast], #[Index]), reducing manual migration churn.

Gotchas and Tips

  • ⚠️ Experimental — expect breaking changes

    • Only use in greenfield or low-critical code. Lock versions strictly (^0.18), and track releases.
  • Eloquent events must be enabled

    • Lift relies on model events (saving, saved, etc.). If Event::dispatch() is disabled (e.g., via static::dispatchEvents() override), some features (like watch/immutable behavior) may not work.
  • Name collisions & manual overrides

    • You may optionally define your own public property (e.g., for computed logic) but must use #[IgnoreProperty] to prevent Lift from overwriting it:
      #[IgnoreProperty]
      public string $full_name = '';
      
  • Stale property state after refresh

    • Known in v0.13.1: refresh() may leave stale public properties if not handled. Prefer $model->fresh() to reload fresh model instance.
  • Enum casting requires explicit declaration

    • #[Cast(enum: MyEnum::class)] is not inferred automatically — specify it manually. Works only for string-backed enums.
  • Custom column names in #[Property]

    • Use #[Property(columnName: 'db_field')] when PHP property name ≠ DB column. IDE auto-completion works only if column is explicitly mapped.
  • IDE support requires proper setup

    • Enable Lift’s IDE metadata (ide.json) or use the included #[Property] pattern — VS Code + Intelephense or PhpStorm work best.
  • Immutable & Watched Properties

    • #[Immutable] prevents writes after model creation — great for domain objects. But: immutable only applies to lift-generated properties — custom properties remain mutable.
  • Casting nulls safely

    • Null defaults and nullables are inferred, but ensure DB columns allow NULL — mismatches cause silent hydration bugs. Validate with #[Rules(['nullable'])].
  • Upgrade path

    • Major version bumps (e.g., Laravel 11 → 12 → 13) are well-supported — check changelog before upgrading. All major versions since v0.14.0 target modern Laravel LTS versions.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport