chelout/laravel-relationship-events
Adds missing Eloquent relationship events to Laravel models. Use simple traits (HasOne/Many, BelongsTo/Many, Morph*) to listen for attach/detach/sync, saved/updated, and other relation lifecycle hooks with parent/related context and IDs/attributes.
illuminate/* ^13.0 and PHP ^8.3.#[\Override] attributes and native return types across relation classes and event traits for full PHP 8.3+ type safety.prefer-lowest and prefer-stable), exercising the real consumer install path instead of dev snapshots.morphToMany toggle events and argument-less detach().| Package | Laravel | PHP |
|---|---|---|
v5.x |
13.x |
^8.3 |
v4.x |
12.x |
^8.2 |
v3.x |
11.x |
^8.2 |
v2.x |
10.x |
^8.1 |
Full Changelog: https://github.com/chelout/laravel-relationship-events/compare/v4.0.0...v5.0.0
Added PHP 8 support. Thanks @nhedger !
Fixed #34
Nothing new, just moved to github actions.
Finished documentation.
It is possible to fire event classes via $dispatchesEvents properties:
use Chelout\RelationshipEvents\Relationships\Concerns\HasOneEvents;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
use HasOneEvents;
protected $dispatchesEvents = [
'hasOneSaved' => HasOneSaved::class,
];
}
How can I help you explore Laravel packages today?