<?php

declare(strict_types=1);

namespace Kylin\Pet\Models;

use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Kylin\Core\Models\BaseModel;

/**
 * 宠物模型
 *
 * 依据 GB/T 45295-2025《宠物健康管理规范》第 4 条：
 * BCS 体况评分 1-9 分制。
 *
 * @property int    $id
 * @property string $name           宠物名称
 * @property string $species        物种（dog/cat/other）
 * @property string $breed          品种
 * @property int    $age            年龄
 * @property float  $weight         体重（kg）
 * @property int    $bcs_score      BCS 体况评分（1-9）
 * @property string $owner_name     主人姓名
 * @property string $owner_phone    主人手机号（加密）
 * @property string $status         状态
 */
class Pet extends BaseModel
{
    protected $table = 'kylin_pet_pets';

    protected $fillable = [
        'name', 'species', 'breed', 'age',
        'weight', 'bcs_score', 'owner_name',
        'owner_phone', 'status',
    ];

    protected $casts = [
        'age' => 'integer',
        'weight' => 'float',
        'bcs_score' => 'integer',
        'owner_phone' => 'encrypted',
    ];

    public function medicalRecords(): HasMany
    {
        return $this->hasMany(PetMedicalRecord::class, 'pet_id');
    }

    public function vaccineRecords(): HasMany
    {
        return $this->hasMany(PetVaccine::class, 'pet_id');
    }

    public function boardingRecords(): HasMany
    {
        return $this->hasMany(PetBoarding::class, 'pet_id');
    }
}