PHPackages                             thoth-pharaoh/operation-record - 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. thoth-pharaoh/operation-record

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

thoth-pharaoh/operation-record
==============================

操作記錄-收集器

v3.0.2(3y ago)030MITPHPPHP ^8.0

Since Sep 25Pushed 3y ago1 watchersCompare

[ Source](https://github.com/castion2293/operation-record)[ Packagist](https://packagist.org/packages/thoth-pharaoh/operation-record)[ RSS](/packages/thoth-pharaoh-operation-record/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (36)Used By (0)

操作記錄-收集器
========

[](#操作記錄-收集器)

版本匹配
----

[](#版本匹配)

Laravelpackage8.X2.X9.X3.X安裝
--

[](#安裝)

你可以使用 composer 做安裝

```
composer require thoth-pharaoh/operation-record
```

Migrate operation\_records 資料表

```
php artisan migrate
```

匯出 Migration

```
php artisan vendor:publish --tag=operation-record-database --force
```

匯出 Config

```
php artisan vendor:publish --tag=operation-record-config --force
```

使用方法
----

[](#使用方法)

### 使用 model 關聯:

[](#使用-model-關聯)

先在要使用的 model 中 引入 HasOperationRecord trait

```
use Pharaoh\OperationRecord\Traits\HasOperationRecord;

class User extends Model
{
    use HasOperationRecord;
}
```

- 操作者 Model 修改 操作對象 Model 寫紀錄

```
$user = new \App\Models\User;
$user->operating($subject, $funcKey, $action, $old, $new, $ip);
```

參數說明類型範例$subject操作對象 modelModel$funcKey功能 KEYint1001$action動做int1$old修改前內容array\['title' =&gt; 'before'\]$new修改後內容array\['title' =&gt; 'after'\]$ipstring操作者 IP127.0.0.1> $action 動作參數 請參閱 config.operation\_record.action 內容

- 操作對象 Model 被 操作者 Model 修改 寫紀錄

```
$post = new \App\Models\Post;
$post->operatedBy($operator, $funcKey, $action $old, $new, $ip);
```

參數說明類型範例$operator操作者 modelModel$funcKey功能 KEYint1001$action動做int1$old修改前內容array\['title' =&gt; 'before'\]$new修改後內容array\['title' =&gt; 'after'\]$ipstring操作者 IP127.0.0.1- 操作者 Model 獲取修改記錄

```
$user = new \App\Models\User;
$records = $user->getOperatorRecords()->get();
```

- 操作對象 Model 獲取被修改紀錄

```
$post = new \App\Models\Post;
$records = $post->getSubjectRecords()->get();
```

### 使用 Facade:

[](#使用-facade)

先引入門面

```
use Pharaoh\OperationRecord\Facades\OperationRecord;

```

- 建立一筆 操作記錄

```
OperationRecord::create($operatorId, $operatorType, $subjectId, $subjectType, $funcKey, $action ,$old, $new $ip);
```

參數說明類型範例$operatorId操作者 IDint123$operatorType操作者 Model 類型stringUser::class$subjectId操作對象 IDint456$subjectType操作對象 Model 類型stringPost::class$funcKey功能 KEYint1001$action動做int1$old修改前內容array\['title' =&gt; 'before'\]$new修改後內容array\['title' =&gt; 'after'\]$ipstring操作者 IP127.0.0.1- 建立一筆 操作記錄(使用 queue job 的方式)

```
OperationRecord::dispatch($operatorId, $operatorType, $subjectId, $subjectType, $funcKey, $action, $old, $new $ip);
```

queue 名稱 以 config/operation\_record.php 裡設定的名稱為主

- 搜尋操作紀錄

```
$params = [
    'operator' => [
        'id' => 1,
        'type' => User::class,
    ],
    'subject' => [
        'id' => [2, 3],
        'type' => Post::class,
    ],
    .....
];

OperationRecord::find($params);
```

$params 內容可以自定義選則搭配，可選項目如下:

參數欄位說明預設operator\['id'\]操作者 ID一筆使用 int (ex: 1) 多筆使用 array (ex: \[1, 2, 3\])operator\['type'\]操作者 model 類型model類別名稱 (ex:User::class)subject\['id'\]操作對象 ID一筆使用 int (ex: 4) 多筆使用 array (ex: \[4, 5, 6\])subject\['type'\]操作對象 model 類型model類別名稱 (ex:Post::class)action動做參閱 config.operation\_record.action內容func\_key功能 KEY一筆使用 int (ex: 1001) 多筆使用 array (ex: \[1001, 1002, 1003\])begin\_at開始時間datatime '2020-09-27 00:00:00'當日 00:00:00end\_at結束時間datatime '2020-09-27 23:59:59'當日 23:59:59sort時間排序string 正序 'asc' 倒序 'desc''desc'page第幾頁int 11per\_page每頁幾筆int 1010- 移除 $datetime 前的 操作記錄

```
$dataTime = '2020-07-30 00:00:00'

OperationRecord::removeBefore($dataTime);
```

- 移除 $datetime 後的 操作記錄

```
$dataTime = '2020-07-30 00:00:00'

OperationRecord::removeAfter($dataTime);
```

- 清空操作記錄

```
OperationRecord::truncate();
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity71

Established project with proven stability

 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 ~26 days

Recently: every ~164 days

Total

35

Last Release

1180d ago

Major Versions

v1.1.18 → v2.0.02021-04-14

v2.0.10 → v3.0.02022-03-20

PHP version history (3 changes)v1.0.32PHP &gt;=7.3

v1.1.17PHP ^7.3|^8.0

v1.1.18PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/f2c93261d26309cd6e0f93f11c0703d9e2c7e6d9ad068d19a7111fdb85d181f9?d=identicon)[castion2293](/maintainers/castion2293)

---

Top Contributors

[![castion2293](https://avatars.githubusercontent.com/u/20082281?v=4)](https://github.com/castion2293 "castion2293 (32 commits)")

### Embed Badge

![Health badge](/badges/thoth-pharaoh-operation-record/health.svg)

```
[![Health](https://phpackages.com/badges/thoth-pharaoh-operation-record/health.svg)](https://phpackages.com/packages/thoth-pharaoh-operation-record)
```

###  Alternatives

[stevebauman/location

Retrieve a user's location by their IP Address

1.3k7.6M65](/packages/stevebauman-location)[nativephp/mobile

NativePHP for Mobile

82724.0k43](/packages/nativephp-mobile)[bensampo/laravel-embed

Painless responsive embeds for videos, slideshows and more.

142146.8k](/packages/bensampo-laravel-embed)[glhd/conveyor-belt

14797.0k](/packages/glhd-conveyor-belt)[pulkitjalan/ip-geolocation

IP Geolocation Wrapper with Laravel Support

89164.9k1](/packages/pulkitjalan-ip-geolocation)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)

PHPackages © 2026

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