pdv.backend/app/Models/ClientTierHistory.php
2026-01-28 16:46:31 -06:00

52 lines
999 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class ClientTierHistory extends Model
{
protected $table = 'client_tier_history';
public $timestamps = false;
protected $fillable = [
'client_id',
'old_tier_id',
'new_tier_id',
'total_at_change',
'reason',
'changed_at',
];
protected $casts = [
'total_at_change' => 'decimal:2',
'changed_at' => 'datetime',
];
/**
* Cliente con historial de niveles
*/
public function client(): BelongsTo
{
return $this->belongsTo(Client::class);
}
/**
* Nivel anterior
*/
public function oldTier(): BelongsTo
{
return $this->belongsTo(ClientTier::class, 'old_tier_id');
}
/**
* Nivel nuevo
*/
public function newTier(): BelongsTo
{
return $this->belongsTo(ClientTier::class, 'new_tier_id');
}
}