Files
reservas/app/Domain/Audit/Models/AuditLog.php

36 lines
900 B
PHP

<?php
namespace App\Domain\Audit\Models;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphTo;
class AuditLog extends Model
{
public const UPDATED_AT = null;
protected $fillable = [
'actor_id', 'event', 'auditable_type', 'auditable_id', 'ip_address',
'user_agent', 'before', 'after', 'metadata', 'created_at',
];
protected function casts(): array
{
return ['before' => 'array', 'after' => 'array', 'metadata' => 'array', 'created_at' => 'datetime'];
}
/** @return BelongsTo<User, $this> */
public function actor(): BelongsTo
{
return $this->belongsTo(User::class, 'actor_id');
}
/** @return MorphTo<Model, $this> */
public function auditable(): MorphTo
{
return $this->morphTo();
}
}