<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class TerminalKnowledgeBase extends Model
{
    /**
     * 可批量赋值的属性
     *
     * @var array<string>
     */
    protected $fillable = [
        'terminal_id',
        'knowledge_base_id',
        'priority',
    ];

    /**
     * 属性类型转换
     *
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'priority' => 'integer',
        ];
    }

    /**
     * 获取关联的终端
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function terminal(): BelongsTo
    {
        return $this->belongsTo(Terminal::class);
    }

    /**
     * 获取关联的知识库
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function knowledgeBase(): BelongsTo
    {
        return $this->belongsTo(KnowledgeBase::class);
    }
}
