feat: prompt from station
This commit is contained in:
@@ -26,6 +26,7 @@ class Terminal extends Model
|
||||
'diagram_urls',
|
||||
'scada_data_url',
|
||||
'scada_tags_url',
|
||||
'prompt_template',
|
||||
'voice_wakeup_enabled',
|
||||
'voice_wakeup_word',
|
||||
'is_online',
|
||||
@@ -57,16 +58,6 @@ class Terminal extends Model
|
||||
return $this->belongsTo(Station::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取终端的提示词配置
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function prompt()
|
||||
{
|
||||
return $this->hasOne(TerminalPrompt::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置活动日志选项
|
||||
*
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
|
||||
class TerminalPrompt extends Model
|
||||
{
|
||||
use LogsActivity;
|
||||
/**
|
||||
* 可批量赋值的属性
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'terminal_id',
|
||||
'prompt_template',
|
||||
'variables',
|
||||
];
|
||||
|
||||
/**
|
||||
* 属性类型转换
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'variables' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提示词所属的终端
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function terminal()
|
||||
{
|
||||
return $this->belongsTo(Terminal::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置活动日志选项
|
||||
*
|
||||
* @return \Spatie\Activitylog\LogOptions
|
||||
*/
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logOnly(['terminal_id', 'prompt_template', 'variables'])
|
||||
->logOnlyDirty()
|
||||
->setDescriptionForEvent(fn(string $eventName) => "终端提示词已{$eventName}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user