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

Events

Lift provides three attributes to help you manage your model's events.

Listener

The Listener attribute allows you to register a listener function for model events.

A more convenient way of registering a listener function "replacing" laravels event closures for eloquent models, more info Laravel Docs: Eloquent Closures

use Illuminate\Database\Eloquent\Model;
use WendellAdriel\Lift\Attributes\Events\Listener;
use WendellAdriel\Lift\Lift;

final class Product extends Model
{
    use Lift;


    #[Listener]
    public function onCreated(Product $product) {
    	Log::info("Product {$product->name} has been created.");
    }
}

API

#[Listener(event: 'created', queue: true)]

event needs to be one of Laravel's model event e.g: 'created', 'creating', 'updated'. If you set queue to true your handler will be executed async by Laravel's queue system.

⚠️ If your function name is equal to the event name prefixed with "on" like onSaving or onDelete you don't need to specify the event name with the Listener Attribute

Observer

The Observer attribute allows you to register a observer class for model events.

This is used to register a Observer Class with a model explained in more detail here: Laravel Docs: Eloquent Observers

use Illuminate\Database\Eloquent\Model;
use WendellAdriel\Lift\Attributes\Events\Observer;
use WendellAdriel\Lift\Lift;


#[Observer(ProductObserver::class)]
final class Product extends Model
{
    use Lift;

}

API

#[Observer(string $observer)]

With this attribute you can register a observer to your model, in theory you could register as many observer classes as you want.

Dispatches

The Dispatches attribute allows you to dispatch custom Laravel Events.

use Illuminate\Database\Eloquent\Model;
use WendellAdriel\Lift\Attributes\Events\Observer;
use WendellAdriel\Lift\Lift;


#[Dispatches(ProductSaved::class)]
#[Dispatches(ProductHasBeenSetup::class, 'created')]
final class Product extends Model
{
    use Lift;

}

API

#[Dispatches(string $eventClass, string $event = '')]

event needs to be one of Laravel's model event e.g: 'created', 'creating', 'updated', but is optional if your eventClass contains the event string in its name like ProductSaved, saved will be interpreted as the event.

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