<?php

namespace App\Models\Tenant;

use App\Models\Concerns\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class InjectorProtocolRow extends Model
{
    use BelongsToTenant;

    protected $fillable = [
        'company_id', 'injector_protocol_id', 'position',
        'resistance_before', 'resistance_after',
        'open_time_before', 'open_time_after',
        'close_time_before', 'close_time_after',
        'close_time_kz_before', 'close_time_kz_after',
        'flow_before', 'flow_after',
        'tightness_before', 'tightness_after',
    ];

    protected $casts = [
        'position' => 'integer',
        'resistance_before' => 'decimal:2',
        'resistance_after' => 'decimal:2',
        'open_time_before' => 'decimal:2',
        'open_time_after' => 'decimal:2',
        'close_time_before' => 'decimal:2',
        'close_time_after' => 'decimal:2',
        'close_time_kz_before' => 'decimal:2',
        'close_time_kz_after' => 'decimal:2',
        'flow_before' => 'decimal:2',
        'flow_after' => 'decimal:2',
    ];

    public function protocol(): BelongsTo
    {
        return $this->belongsTo(InjectorProtocol::class, 'injector_protocol_id');
    }
}
