<?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\ComplaintStatus;

/**
 * 投诉建议
 */
class Complaint extends Model
{
    protected $fillable = [
        'resident_id',
        'type',
        'content',
        'status',
        'images',
        'is_anonymous',
    ];

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

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

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