<?php

namespace Kylin\Community\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Kylin\Community\Enums\HelpStatus;

/**
 * 互助需求
 */
class Help extends Model
{
    protected $fillable = [
        'resident_id',
        'type',
        'title',
        'content',
        'status',
        'images',
    ];

    protected function casts(): array
    {
        return [
            'status' => HelpStatus::class,
            'images' => 'array',
        ];
    }

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

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