Laravel Fireable Attributes

Laravel Fireable Attributes

Laravel Fireable is a package by Boris Lepikhin that provides “an elegant way to trigger Laravel events based on attributes changes.”

Here’s an example from the project’s documentation that shows how this package works. In this example, updating a user’s status attribute triggers a UserApproved event:

class User extends Authenticatable
{
    use FireableAttributes;

    protected $fireableAttributes = [
        'status' => [
            'approved' => UserApproved::class,
            'rejected' => UserRejected::class,
        ],
    ];
}

In some cases, you want to trigger an event whenever an attribute is changed regardless of its value:

class User extends Authenticatable
{
    use FireableAttributes;

    protected $fireableAttributes = [
        'email' => EmailUpdated::class,
    ];
}

To learn more about this package, get full installation instructions, and view the source code on GitHub at envant/fireable.

Filed in: News / packages

Newsletter

Join 31,000+ others and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Senior Laravel Developer
Remote
FPV Exchange
Senior Full-Stack Developer
Remote, USA Only
Givebutter
Full Stack Web Developer
Greenville, TX (or Remote, US)
Innovation First International, Inc.
Senior Software Developer
UK/Germany Only
The Greenhouse People Ltd
Senior PHP Developer
Cary, NC
INE