skore-labs/laravel-auditable
Composer 安装命令:
composer require skore-labs/laravel-auditable
包简介
Simple audit for users that performs actions to your Eloquent models
README 文档
README
Audit the users that performs actions to your application models
Status
Getting started
composer require skore-labs/laravel-auditable
And write this on the models you want to have auditables:
<?php namespace SkoreLabs\LaravelAuditable\Tests\Fixtures; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use SkoreLabs\LaravelAuditable\Traits\Auditable; class Post extends Model { use Auditable; // Add this one and it will auto-detect for the deletedBy // use SoftDeletes; /** * The attributes that should be visible in serialization. * * @var array */ protected $visible = ['title', 'content']; }
And this is how it should look like in your migration file:
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; class CreatePostsTestTable extends Migration { public function up() { Schema::create('posts', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('title'); $table->text('content'); $table->timestamps(); $table->softDeletes(); $table->auditables(); // or if has softDeletes (deleted_at column): $table->auditables(true); // also you might want to rename the users table: $table->auditables(true, 'my_users_table'); }); } public function down() { Schema::dropIfExists('posts'); } }
Note: If you wanna remove it on the down method of your migrations, you can use dropAuditables.
public function down() { Schema::table('posts', function (Blueprint $table) { $table->dropAuditables(); // or if has softDeletes (deleted_at column): $table->dropAuditables(true); }); }
Methods
These are all the relationships that the Auditable trait provides to your model:
$post = Post::first(); $post->createdBy; // Author of the post $post->updatedBy; // Author of the last update of the post $post->deletedBy; // Author of the deletion of the post $post->author; // Alias for createdBy
Support
This and all of our Laravel packages follows as much as possibly can the LTS support of Laravel.
Read more: https://laravel.com/docs/master/releases#support-policy
Credits
- Ruben Robles (@d8vjork)
- Skore (https://www.getskore.com/)
- And all the contributors
skore-labs/laravel-auditable 适用场景与选型建议
skore-labs/laravel-auditable 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 623 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 03 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 skore-labs/laravel-auditable 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 skore-labs/laravel-auditable 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 623
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-03-12