<?php

namespace App\Models;

use App\Traits\AuditLogTrait;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class AliqoutMovement extends BaseModel
{
    public $timestamps = false;

    use HasFactory;
    use AuditLogTrait;

    /**
     * The database schema currently uses the legacy misspelling "aliqout".
     */
    protected $table = 'aliqout_movements';

    protected $primaryKey = 'id';

    protected $fillable = [
        'aliquot_id',
        'from_position_id',
        'to_position_id',
        'movement_reason',
        'moved_by',
        BaseModel::CREATED_AT_FIELD,
        BaseModel::CREATED_BY_FIELD,
        BaseModel::UPDATED_AT_FIELD,
        BaseModel::UPDATED_BY_FIELD,
        BaseModel::DELETED_AT_FIELD,
        BaseModel::DELETED_BY_FIELD,
        BaseModel::RECORD_STATUS_FIELD,
    ];

    public static function boot()
    {
        parent::boot();
    }

    public function aliquot()
    {
        return $this->belongsTo(Aliquot::class, 'aliquot_id', 'id');
    }

    public function fromPosition()
    {
        return $this->belongsTo(Position::class, 'from_position_id', 'id');
    }

    public function toPosition()
    {
        return $this->belongsTo(Position::class, 'to_position_id', 'id');
    }
}
