Register model observers using php 8 attributes
gpanos/laravel-observe-attribute is a Laravel package for register model observers using php 8 attributes.
It currently has 15 GitHub stars and 5 downloads on Packagist (latest version 1.0.0).
Install it with composer require gpanos/laravel-observe-attribute.
Discover more Laravel packages by gpanos
or browse all Laravel packages to compare alternatives.
Last updated
Instead of defining observers inside service providers this package offers an alternative way to register model observers for your Laravel applications.
Inspired by spatie/laravel-route-attributes
composer require gpanos/laravel-observe-attribute
To register an observer add the Observe attribute to your model and pass it your observer class.
<?php
#[Observe(UserObserver::class)]
class User extends Authenticatable
{
...
}