<?php

namespace App\Models;

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

class Loan extends Model
{
    use SoftDeletes;

    protected $fillable = ['employee_id', 'sparepart_id', 'borrowed_at', 'returned_at', 'status', 'notes'];

    protected $casts = [
        'borrowed_at' => 'datetime',
        'returned_at' => 'datetime',
    ];

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

    public function sparepart()
    {
        return $this->belongsTo(Sparepart::class);
    }
}
