59 lines
1 KiB
PHP
59 lines
1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class LlmProvider extends Model
|
|
{
|
|
/**
|
|
* 提供商状态常量
|
|
*/
|
|
public const STATUS_ACTIVE = 'active';
|
|
public const STATUS_INACTIVE = 'inactive';
|
|
|
|
/**
|
|
* 有效的状态列表
|
|
*/
|
|
public const VALID_STATUSES = [
|
|
self::STATUS_ACTIVE,
|
|
self::STATUS_INACTIVE,
|
|
];
|
|
|
|
protected $table = 'llm_providers';
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'service_name',
|
|
'api_url',
|
|
'api_token',
|
|
'status',
|
|
];
|
|
|
|
protected $hidden = [
|
|
'api_token',
|
|
];
|
|
|
|
protected $casts = [
|
|
'status' => 'string',
|
|
];
|
|
|
|
/**
|
|
* @return HasMany<Client>
|
|
*/
|
|
public function clients(): HasMany
|
|
{
|
|
return $this->hasMany(Client::class);
|
|
}
|
|
|
|
/**
|
|
* 检查提供商是否处于活跃状态
|
|
*/
|
|
public function isActive(): bool
|
|
{
|
|
return $this->status === self::STATUS_ACTIVE;
|
|
}
|
|
}
|