<?php

namespace App\Models\Care;

use App\Models\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class CarePlan extends Model
{
    protected $fillable = [
        'care_profile_id', 'plan_date', 'stage', 'items',
        'nurse_id', 'status',
    ];

    protected function casts(): array
    {
        return [
            'plan_date' => 'date',
            'items' => 'array',
            'status' => 'integer',
        ];
    }

    public function profile(): BelongsTo
    {
        return $this->belongsTo(CareProfile::class, 'care_profile_id');
    }

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

    public function records(): HasMany
    {
        return $this->hasMany(CareRecord::class);
    }
}
