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.
Pros:
Cast attributes improves developer experience and runtime correctness, especially for complex data types (e.g., CarbonImmutable, nested arrays).Watch attribute) enable fine-grained reactivity (e.g., triggering custom events for specific property changes), useful for audit logs or workflows.Cons:
$casts, $fillable arrays) if not migrated incrementally.#[DB], but complex migrations (e.g., schema changes) may require manual intervention.#[Cast]) requires PHP 8.0+ and modern IDEs (PhpStorm/VSCode).create()).Watch) may introduce tight coupling if overused. Evaluate event dispatching costs in high-frequency systems.ImmutablePropertyException) could disrupt debugging flows if not handled gracefully.$casts, $fillable, etc., will require dual maintenance during transition.castAndCreate) may complicate future Laravel upgrades.$casts, $fillable, etc., be deprecated/merged?create(), update())?Model::insert())?ImmutablePropertyException and validation errors be surfaced to APIs/clients?Cast attributes).Product, UserProfile) to validate:
$casts, $fillable, etc., with attributes one model at a time.// Before
protected $casts = ['price' => 'float'];
protected $fillable = ['name', 'price'];
// After
#[Cast('float')]
#[Fillable]
public float $price;
castAndCreate).shouldUseNewAttributes() or custom trait.hasManyThrough) to attributes if beneficial.use WendellAdriel\Lift\Lift;
final class Product extends Model {
use Lift;
// Lift attributes
#[Cast('float')]
public float $price;
// Legacy fallback (if needed)
protected $casts = ['price' => 'float'];
}
observables, audit-trail) may need updates to handle Lift’s custom events (Watch).spatie/laravel-medialibrary (custom casts).laravel-breeze/laravel-jetstream (auth models).php-version checks in composer.json.#[Column(default: ...)]) must match DB constraints.$guarded, $hidden).OrderItem, InvoiceLine) where type safety is critical.ActivityLog) until stability is proven.FormRequest rules with #[Rules] attributes where applicable.composer require wendelladriel/laravel-lift --dev # Temporarily remove
#[Rules]) simplifies updates (e.g., changing max:255 to max:500).ImmutablePropertyException or event failures may be less intuitive than traditional Eloquent errors.WendellAdriel) for critical updates.#[Cast('float')] clarifies intent).castAndCreate).#[Immutable] for IDs").Cast failures during create()/update() (e.g., passing a string to an int field).Watch events causing performance spikes.ImmutablePropertyException occurrences.How can I help you explore Laravel packages today?