PHPackages                             tedon/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. tedon/laravel-actor

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

tedon/laravel-actor
===================

A brand option to have specific action fields in model.

v1.2.3(2y ago)2124MITPHPPHP &gt;=8.0

Since Apr 17Pushed 2y ago1 watchersCompare

[ Source](https://github.com/zouravand/laravel-actor)[ Packagist](https://packagist.org/packages/tedon/laravel-actor)[ RSS](/packages/tedon-laravel-actor/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (12)Used By (0)

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

[](#laravel-actor)

A brand option to have auto generated specific action fields in model. Using this package helps you universalize fields along your team.

Installation
------------

[](#installation)

In order to add the capability to your laravel application, you should require it via composer.

```
composer require tedon/laravel-actor
```

### Publish configuration file

[](#publish-configuration-file)

By publishing configuration file, it is possible to edit predefined custom shortcut macros.

```
php artisan vendor:publish --provider="Tedon\LaravelActor\Providers\ActorServiceProvider" --tag="actor-config"
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

You can use actor as a macro in migrations. Verb form of action is passed as the first argument.

```
Schema::table('users', function (Blueprint $table) {
    ...
    $table->actor('test');
    ...
});
```

In the provided example, `$table->actor('test');` will create fields `tester_id` and `tester_type`

Shortcut Macros
---------------

[](#shortcut-macros)

You can use some macros as shortcuts. by default, `creator` and `editor` macros is defined.

```
Schema::table('users', function (Blueprint $table) {
    ...
    $table->creator();
    $table->editor();
    ...
});
```

In the provided example, fields `creator_id`, `creator_type`, `editor_id` and `editor_type` is created for users table.

### Define Custom Shortcut Macros

[](#define-custom-shortcut-macros)

use the provided config file to add or remove custom shortcut macros.

```
return [
    'custom-macros' => [
        'edit',
        'approve',
    ]
];
```

In the provided example, the `create` macro is remove and the `approve` macro is added to the code;

Model Traits
------------

[](#model-traits)

There is a trait provided in the package: `Actorable`. The `actorable` function is defined to handle auto-set feature.

```
use \Tedon\LaravelActor\Traits\Actorable;

class User
{
    use Actorable;

    public function actorable(): array
    {
        return [
            'actions' => [
                'edit'
            ]
        ];
    }
}
```

In the example above, `edit`-related fields is set on model update automatically. Currently, The `create` action is also available to be auto-set.

Retrieve Actor Data
-------------------

[](#retrieve-actor-data)

Though you can access to fields directly by field name, there are some functions to access actor data.

### Available Methods:

[](#available-methods)

The following methods is added by using `Actorable` trait on the model. It is totally clear that the macros in migration should be used before to generate related columns.

#### Get Actor ID:

[](#get-actor-id)

Retrieve actor id of given action.

```
getActorId(string $action): int|string;

//  example output: 13
```

#### Get Actor Type:

[](#get-actor-type)

Retrieve actor type of given action.

```
getActorType(string $action): ?string;

//  example output: "\App\Models\User"
```

#### Get Acted At:

[](#get-acted-at)

Retrieve the time when given action is acted at.

```
getActedAt(string $action): ?Carbon;

//  example output: "2023-04-30 15:30:04"
```

#### Get Actor:

[](#get-actor)

Retrieve the actor model.

```
getActor(string $action): ?Model;
```

#### Get Act:

[](#get-act)

Returns an array containing all above data.

```
getAct(string $action): array;

//  example output: [
//    'editor_id' => 13,
//    'editor_type' => "\App\Models\User",
//    'edited_at' => "2023-04-30 15:30:04",
//  ]
```

Set Actor Data
--------------

[](#set-actor-data)

The action field can be set with methods below.

### Touch Action

[](#touch-action)

This method is provided to set all action fields at the same time with the authenticated user.

```
touchAction(string $action, bool $isForce = false): void;
```

### Clear Action

[](#clear-action)

This method is provided to clear all action fields at the same time.

```
cleanAction(string $action): void;
```

Check and filter Actor Data
---------------------------

[](#check-and-filter-actor-data)

These accessories are used for checking and filtering action data

### Check If Is Acted By

[](#check-if-is-acted-by)

This method is used for checking if the model is acted by specific user on a specific action

```
isActedBy(string $action, ?Authenticatable $user): bool;
```

returns `true` if the model is acted on the action by the given user.

### Acted By Scope

[](#acted-by-scope)

There is a scope provided for filtering the actorable model data to get record with the given actor on the given action.

```
$query
...
    ->actedBy('create', $user)
...
```

The expression above scopes actorable model query with the given action and given authenticatable user.

License
-------

[](#license)

The Laravel Actor package is open-sourced software licensed under the MIT license.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~28 days

Recently: every ~57 days

Total

10

Last Release

863d ago

Major Versions

v0.2.1 → v1.2.32023-12-29

### Community

Maintainers

![](https://www.gravatar.com/avatar/ae3a667533c45f88ba513ab71d1bf17df37c99c0b918e60160b49ce6a7ae5adc?d=identicon)[pouya.zuravand](/maintainers/pouya.zuravand)

---

Top Contributors

[![zouravand](https://avatars.githubusercontent.com/u/4015493?v=4)](https://github.com/zouravand "zouravand (42 commits)")

---

Tags

laravelactionactorTedonLaravelActionLaravelActor

### Embed Badge

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

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

###  Alternatives

[tormjens/eventy

The WordPress filter/action system in Laravel

438912.9k16](/packages/tormjens-eventy)[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

14720.0k](/packages/markwalet-nova-modal-response)[prevailexcel/laravel-action-service-trait

A simple Laravel package to create actions, traits and services using artisan commands

143.0k](/packages/prevailexcel-laravel-action-service-trait)

PHPackages © 2026

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