<?php

namespace App\Models;

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

class RequirementOperation extends Model
{
    use HasFactory;

    protected $table = 'requirement_operations';

    protected $fillable = [
        'user_id',
        'r_id',
        'nfu_id',
        'project_id',
        'nfu_value',
        'status'
    ];

    /**
     * Get the user associated with this operation.
     */
    public function user()
    {
        return $this->belongsTo(User::class);
    }

    /**
     * Get the requirement associated with this operation.
     */
    public function requirement()
    {
        return $this->belongsTo(Requirement::class, 'r_id');
    }

    /**
     * Get the non-functional requirement associated with this operation.
     */
    public function nonFunctionalRequirement()
    {
        return $this->belongsTo(NonFunctionalRequirement::class, 'nfu_id');
    }

    /**
     * Get the project associated with this operation.
     */
    public function project()
    {
        return $this->belongsTo(Project::class, 'project_id'); 
    }
}