<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Concerns\HasUuids;

class Allocation extends Model
{
    use HasFactory, HasUuids;

    protected $primaryKey = 'id';
    public $incrementing = false;
    protected $keyType = 'string';

    protected $fillable = [
        'project_id',
        'team_member_id',
        'month',
        'allocated_hours',
    ];

    protected $casts = [
        'month' => 'date',
        'allocated_hours' => 'decimal:2',
    ];

    /**
     * Get the project that owns the allocation.
     */
    public function project()
    {
        return $this->belongsTo(Project::class);
    }

    /**
     * Get the team member that owns the allocation.
     */
    public function teamMember()
    {
        return $this->belongsTo(TeamMember::class);
    }
}
