<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use App\Models\User;

class Deferment extends Model
{
    use HasFactory;

    protected $table = 'deferments';

    protected $fillable = [
        'registration_number',
        'reason',
        'attachment',
        'status',
    ];

    /**
     * Get the user associated with the deferment via registration_number.
     * Assumes registration_number exists in both deferments and users tables.
     */
    public function user()
    {
        return $this->belongsTo(User::class, 'registration_number', 'registration_number');
    }
}
