Download the PHP package hasyirin/laravel-actor without Composer
On this page you can find all versions of the php package hasyirin/laravel-actor. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hasyirin/laravel-actor
More information about hasyirin/laravel-actor
Files in hasyirin/laravel-actor
Package laravel-actor
Short Description A polymorphic action log for Eloquent models — track who did what, when.
License MIT
Homepage https://github.com/hasyirin/laravel-actor
Informations about the package laravel-actor
Laravel Actor
A small polymorphic action log for Eloquent models. Record that an actor (any model — typically a User) performed a named action on a resource (any model), with the time it happened. Each (resource, name) pair holds a single latest-state row.
Installation
Publish and run the migration:
Optionally publish the config:
Published config:
Usage
Add the trait to any model that should be a resource (the thing being acted on):
Record an action. The current authenticated user is used as the actor unless you pass one explicitly:
Check whether an action has been recorded:
Fetch the action record (or null):
Get all actions on the resource (eager-loadable):
You can also use the facade directly when you don't have a trait-equipped model:
Latest-state semantics
act() is an upsert keyed on (resource_type, resource_id, name). Re-acting the same action on the same resource overwrites the actor and timestamp — there is only ever one row per (resource, name). If you need a full event history, this package is not the right choice.
Authentication guard
If the actor is resolved from auth(), the package uses Laravel's default guard. Override via config:
A missing actor (no parameter, no authenticated user) throws Hasyirin\Actor\Exceptions\MissingActorException.
Testing
Changelog
See CHANGELOG.
Credits
- Hasyirin Fakhriy
- All Contributors
License
The MIT License (MIT). See License File.
All versions of laravel-actor with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^12.0||^13.0