48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\Logging\Models;
|
|
|
|
use App\Domains\Auth\Models\User;
|
|
use App\Domains\Logging\Enums\ValueChangeActorType;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|
|
|
#[Fillable([
|
|
'trackable_type',
|
|
'trackable_id',
|
|
'attribute',
|
|
'old_value',
|
|
'new_value',
|
|
'changed_at',
|
|
'actor_type',
|
|
'user_id',
|
|
])]
|
|
class ValueChange extends Model
|
|
{
|
|
public $timestamps = false;
|
|
|
|
/** @return MorphTo<Model, $this> */
|
|
public function trackable(): MorphTo
|
|
{
|
|
return $this->morphTo();
|
|
}
|
|
|
|
/** @return BelongsTo<User, $this> */
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'trackable_id' => 'integer',
|
|
'changed_at' => 'datetime',
|
|
'actor_type' => ValueChangeActorType::class,
|
|
'user_id' => 'integer',
|
|
];
|
|
}
|
|
}
|