Laravel 更新审计在我的 laravel eloquent 应用程序中的几个模型中不起作用。除了用户模型。以下是audit.php
事件
'events' => [
'created',
'updated',
'deleted',
'restored',
],
'strict' => false,
'timestamps' => true,
'console' => true,
我设置我的模型如下
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use OwenIt\Auditing\Contracts\Auditable;
use Illuminate\Support\Arr;
class Order extends Model implements Auditable
use \OwenIt\Auditing\Auditable;
use HasFactory;
protected $fillable = [
'order_date',
'cancel_date',
'comment',
'remark',
'customer_auto_id',
'customer',
];
public function transformAudit(array $data): array
{
Arr::set($data, 'recode_auto_id', $this->attributes['id']);
return $data;
}
public function customer()
{
return $this->hasOne(User::class, 'id', 'customer_auto_id');
}
}
除了更新而不是审计之外,创建和删除在审计时工作正常。请让我知道解决方案。