Written from model events, spatie's role events and panel sign-ins, only for what a person did, with secrets masked; pruned after a year. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
47 lines
969 B
PHP
47 lines
969 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\MassPrunable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* One thing somebody did. Written by App\Support\Audit\Auditor, never edited.
|
|
*/
|
|
class AuditLog extends Model
|
|
{
|
|
use MassPrunable;
|
|
|
|
public const UPDATED_AT = null;
|
|
|
|
protected $guarded = [];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'changes' => 'array',
|
|
'created_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<User, $this>
|
|
*/
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
/**
|
|
* @return Builder<$this>
|
|
*/
|
|
public function prunable(): Builder
|
|
{
|
|
return static::query()->where('created_at', '<', now()->subDays((int) config('audit.retention_days', 365)));
|
|
}
|
|
}
|