Skip to content

Eventix/eloquent-extra-events

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 

Repository files navigation

eloquent-extra-events

Total Downloads Monthly Downloads Daily Downloads Latest Stable Version Latest Unstable Version License

Install:

For 5.2.x, 5.3.x and 5.4.x:
composer require neylsongularte/eloquent-extra-events:0.3.5
For 5.5.x:
composer require neylsongularte/eloquent-extra-events

In your model:

use NeylsonGularte\EloquentExtraEvents\ExtraEventsTrait;

Events:

  • eloquent.syncing
  • eloquent.synced
  • eloquent.attaching
  • eloquent.attached
  • eloquent.detaching
  • eloquent.detached

Listen events in App\Providers\AppServiceProvider:

In 5.2.x and 5.3.x:
Event::listen('eloquent.syncing*', function (array $eventData) {
});

In 5.4.x and 5.5.x:
Event::listen('eloquent.syncing*', function ($eventName, array $eventData) {
});

Available properties:

  • $eventData['parent_model']: string e.g. 'App\Models\Model'
  • $eventData['parent_id']: integer e.g. 42
  • $eventData['related_model']: string e.g. 'App\Models\Model'
  • (except eloquent.synced) $eventData['related_ids']: array e.g. [31,41]
  • (Only eloquent.detached) $eventData['results']: integer e.g. 2
  • (Only eloquent.synced) $eventData['changes']: array with the following keys:
    • 'attached': array e.g. [1, 8]
    • 'detached': array e.g. [15, 16]
    • 'updated': array e.g. [23]

Note: sync trigger attach and detach.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%