PHPackages                             hasyirin/laravel-actor - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. hasyirin/laravel-actor

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hasyirin/laravel-actor
======================

A polymorphic action log for Eloquent models — track who did what, when.

v1.1.0(1mo ago)0203MITPHPPHP ^8.4CI passing

Since May 14Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/hasyirin/laravel-actor)[ Packagist](https://packagist.org/packages/hasyirin/laravel-actor)[ Docs](https://github.com/hasyirin/laravel-actor)[ GitHub Sponsors]()[ RSS](/packages/hasyirin-laravel-actor/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (13)Versions (9)Used By (0)

Laravel Actor
=============

[](#laravel-actor)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5f9d4c3eeddd0c5c5a9a41ff12c46bc7711dc15f5f9adc6261a4e736541bbb57/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f686173796972696e2f6c61726176656c2d6163746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/hasyirin/laravel-actor)[![GitHub Tests Action Status](https://camo.githubusercontent.com/b8aa653ef678142a92471b47c4960837e7ea746afa7d7f7daa47f43940e9e770/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f686173796972696e2f6c61726176656c2d6163746f722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/hasyirin/laravel-actor/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/3ea2dc526d7efc74125301923f67c604e0ef3d05b35a71f9fe5622457e639f88/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f686173796972696e2f6c61726176656c2d6163746f722f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/hasyirin/laravel-actor/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/d8ce387e874383d68897d34f75652301738104289699024a4dbb2cad83fe73a5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f686173796972696e2f6c61726176656c2d6163746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/hasyirin/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
------------

[](#installation)

```
composer require hasyirin/laravel-actor
```

Publish and run the migration:

```
php artisan vendor:publish --tag="laravel-actor-migrations"
php artisan migrate
```

Optionally publish the config:

```
php artisan vendor:publish --tag="laravel-actor-config"
```

Published config:

```
return [
    'tables' => [
        'actions' => 'actions',
    ],

    'models' => [
        'action' => \Hasyirin\Actor\Models\Action::class,
    ],

    'guard' => null,
];
```

Usage
-----

[](#usage)

Add the trait to any model that should be a resource (the thing being acted on):

```
use Hasyirin\Actor\Concerns\InteractsWithActions;

class Post extends Model
{
    use InteractsWithActions;
}
```

Record an action. The current authenticated user is used as the actor unless you pass one explicitly:

```
$post->act('approved');                          // actor = auth()->user()
$post->act('approved', $editor);                 // explicit actor
$post->act('approved', $editor, now()->subDay()); // explicit time
```

Check whether an action has been recorded:

```
$post->acted('approved');           // bool — anyone approved?
$post->acted('approved', $user);    // bool — is $user the current approver?

```

Fetch the action record (or null):

```
$action = $post->action('approved');
$action?->actor;                    // the user who acted
$action?->acted_at;

$mine = $post->action('approved', $user);  // only if $user is the current approver
```

Get all actions on the resource (eager-loadable):

```
$post->load('actions');
$post->actions; // Collection
```

You can also use the facade directly when you don't have a trait-equipped model:

```
use Hasyirin\Actor\Facades\Actor;

Actor::act($post, 'approved', $editor);
Actor::acted($post, 'approved');                // anyone?
Actor::acted($post, 'approved', $editor);       // is $editor the current actor?
Actor::findAction($post, 'approved');
Actor::findAction($post, 'approved', $editor);  // only if $editor is the current actor
```

### Latest-state semantics

[](#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

[](#authentication-guard)

If the actor is resolved from `auth()`, the package uses Laravel's default guard. Override via config:

```
// config/actor.php
'guard' => 'sanctum',
```

A missing actor (no parameter, no authenticated user) throws `Hasyirin\Actor\Exceptions\MissingActorException`.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

See [CHANGELOG](CHANGELOG.md).

Credits
-------

[](#credits)

- [Hasyirin Fakhriy](https://github.com/hasyirin)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). See [License File](LICENSE.md).

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance90

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 71.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

3

Last Release

45d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25414222?v=4)[Hasyirin Fakhriy](/maintainers/hasyirin)[@hasyirin](https://github.com/hasyirin)

---

Top Contributors

[![hasyirin](https://avatars.githubusercontent.com/u/25414222?v=4)](https://github.com/hasyirin "hasyirin (25 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

---

Tags

laraveltrackingactionsactivity-logaudit-loglaravel-actor

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/hasyirin-laravel-actor/health.svg)

```
[![Health](https://phpackages.com/badges/hasyirin-laravel-actor/health.svg)](https://phpackages.com/packages/hasyirin-laravel-actor)
```

###  Alternatives

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

329530.5k29](/packages/codewithdennis-filament-select-tree)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

124603.0k](/packages/worksome-exchange)[mradder/filament-logger

Audit logging, activity tracking, exports, alerts, and dashboards for Filament admin panels.

2317.4k](/packages/mradder-filament-logger)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
