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
Laravel News Partners

Laravel Jobs

Senior PHP developer
Brussels
Paynovate
PHP Developer - Full time w/ benefits, US Only
Northern Virginia or Remote (US Only)
Guidance Residential
Full Stack Developer
Remote
Wehaa.com
Laravel API Developer
Las Vegas, NV (Must work on-site)
V Shred
Laravel Developer (Vue, SQL Server)
Remote
World Trade Organization

Newsletter

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