friendsofhyperf/model-observer

Model Observer For Hyperf

0.2.0 2021-04-27 00:56 UTC

This package is auto-updated.

Last update: 2021-11-25 10:17:21 UTC


README

Latest Stable Version Total Downloads GitHub license

Installation

composer require friendsofhyperf/model-observer

Usage

  • Generator command
php bin/hyperf.php gen:observer TestObserver --model="App\\Model\\User"
  • Custom
App\Observer;

use App\Model\User;
use FriendsOfHyperf\ModelObserver\Annotation\Observer;

/**
 * @Observer(User::class)
 */
class FooObserver
{
    public function creating(User $model)
    {
        // do sth...
    }

    public function created(User $model)
    {
        // do sth...
    }

    // another events
}

Methods

  • booting
  • booted
  • retrieved
  • creating
  • created
  • updating
  • updated
  • saving
  • saved
  • restoring
  • restored
  • deleting
  • deleted
  • forceDeleted