<?php

namespace App\Models\Care;

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

class CareException extends Model
{
    protected $fillable = [
        'care_profile_id', 'reporter_id', 'level', 'description',
        'images', 'status', 'handler_id', 'handle_result', 'handle_at',
    ];

    protected function casts(): array
    {
        return [
            'level' => 'integer',
            'images' => 'array',
            'status' => 'integer',
            'handle_at' => 'datetime',
        ];
    }

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

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

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