<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;

class ProjectModule extends Model
{
    use HasFactory, SoftDeletes;

    protected $fillable = ['project_id', 'name', 'description', 'sort_order'];

    public function project(): BelongsTo { return $this->belongsTo(Project::class); }
    public function tasks(): HasMany { return $this->hasMany(Task::class); }
    public function knowledgeArticles(): HasMany { return $this->hasMany(KnowledgeArticle::class, 'module_id'); }
    public function bugs(): HasMany { return $this->hasMany(Bug::class, 'module_id'); }
}
