<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class SparepartTransaction extends Model
{
    use HasFactory, SoftDeletes;

    protected $fillable = [
        'sparepart_id',
        'user_id',
        'employee_id',
        'type', // 'in', 'out'
        'quantity',
        'date',
        'note',
    ];

    /**
     * Get the sparepart that owns the transaction.
     */
    public function sparepart()
    {
        return $this->belongsTo(Sparepart::class);
    }

    /**
     * Get the user who created the transaction.
     */
    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function employee()
    {
        return $this->belongsTo(Employee::class);
    }
}
