forked from admin/services_core
update api ticket type
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use App\Services\Audit\AuditLogService;
|
||||
|
||||
trait Auditable
|
||||
{
|
||||
protected static function bootAuditable()
|
||||
{
|
||||
static::created(function ($model) {
|
||||
|
||||
AuditLogService::log(
|
||||
module: strtolower(class_basename($model)),
|
||||
action: 'create',
|
||||
tableName: $model->getTable(),
|
||||
recordId: $model->id,
|
||||
newValues: $model->toArray()
|
||||
);
|
||||
});
|
||||
|
||||
static::updated(function ($model) {
|
||||
|
||||
AuditLogService::log(
|
||||
module: strtolower(class_basename($model)),
|
||||
action: 'update',
|
||||
tableName: $model->getTable(),
|
||||
recordId: $model->id,
|
||||
oldValues: $model->getOriginal(),
|
||||
newValues: $model->getAttributes()
|
||||
);
|
||||
});
|
||||
|
||||
static::deleted(function ($model) {
|
||||
|
||||
AuditLogService::log(
|
||||
module: strtolower(class_basename($model)),
|
||||
action: 'delete',
|
||||
tableName: $model->getTable(),
|
||||
recordId: $model->id,
|
||||
oldValues: $model->toArray()
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user