<?php

namespace App\Models;

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

class Task extends Model
{
    use SoftDeletes;

    protected $fillable = [
        'department_id','title','description','priority','status',
        'start_date','due_date','estimate_minutes','actual_minutes',
        'complexity','created_by'
    ];

    public function department()
    {
        return $this->belongsTo(Department::class);
    }

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

    public function assignees()
{
    return $this->belongsToMany(\App\Models\User::class, 'task_assignees')
        ->withPivot(['assigned_by','assigned_at'])
        ->withTimestamps();
}

}
