refactor(backend): reorganize domains into Core, Commerce, Ticketing and Shared
This commit is contained in:
55
app/Shared/Logging/Models/ValueChange.php
Normal file
55
app/Shared/Logging/Models/ValueChange.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Logging\Models;
|
||||
|
||||
use App\Domains\Auth\Models\User;
|
||||
use App\Domains\Logging\Enums\ValueChangeActorType;
|
||||
use App\Domains\Tenant\Models\Tenant;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
#[Fillable([
|
||||
'tenant_code',
|
||||
'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);
|
||||
}
|
||||
|
||||
/** @return BelongsTo<Tenant, $this> */
|
||||
public function tenant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Tenant::class, 'tenant_code', 'codigo');
|
||||
}
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'trackable_id' => 'integer',
|
||||
'changed_at' => 'datetime',
|
||||
'actor_type' => ValueChangeActorType::class,
|
||||
'user_id' => 'integer',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user