<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class BacklogItem extends Model
{
    protected $fillable = [
        'title', 'description', 'type', 'project_id', 'priority',
        'estimated_effort', 'status', 'assigned_sprint_id', 'converted_to_task_id',
        'archived_at', 'created_by',
    ];

    protected $casts = [
        'archived_at' => 'datetime',
    ];

    public function project(): BelongsTo
    {
        return $this->belongsTo(Project::class);
    }

    public function assignedSprint(): BelongsTo
    {
        return $this->belongsTo(Sprint::class, 'assigned_sprint_id');
    }

    public function creator(): BelongsTo
    {
        return $this->belongsTo(User::class, 'created_by');
    }

    public function convertedTask(): BelongsTo
    {
        return $this->belongsTo(Task::class, 'converted_to_task_id');
    }
}
