gpanos/laravel-observe-attribute

Register model observers using php 8 attributes

1.0.0 2021-08-24 14:41 UTC

This package is auto-updated.

Last update: 2024-11-09 13:49:40 UTC


README

tests code style

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

Installation

composer require gpanos/laravel-observe-attribute

Usage

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
{
    ...
}