All checks were successful
star-cloud-deploy-demo / deploy-demo (push) Successful in 1m6s
1. 修復帳號管理與角色權限頁面搜尋功能,支援 Enter 鍵快捷提交。 2. 完成 B013 (機台故障上報) API 實作,改用非同步隊列 (ProcessMachineError) 處理日誌上報。 3. 精簡 B013 API 參數,移除冗餘的 message 欄位,統一由雲端對照表翻譯。 4. 更新技術規格文件 (SKILL.md) 與系統 API 文件配置 (api-docs.php)。 5. 修正平台管理員帳號在搜尋過濾時的資料隔離邏輯。
59 lines
1.3 KiB
PHP
59 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Machine;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class MachineLog extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
const UPDATED_AT = null;
|
|
|
|
protected $fillable = [
|
|
'company_id',
|
|
'machine_id',
|
|
'level',
|
|
'type',
|
|
'message',
|
|
'context',
|
|
];
|
|
|
|
protected $casts = [
|
|
'context' => 'array',
|
|
];
|
|
|
|
protected $appends = [
|
|
'translated_message',
|
|
];
|
|
|
|
/**
|
|
* 動態重組翻譯後的訊息
|
|
*/
|
|
public function getTranslatedMessageAttribute(): string
|
|
{
|
|
$context = $this->context;
|
|
|
|
// 若 context 中已有翻譯標籤 (B013 封裝),則進行動態重組
|
|
if (isset($context['translated_label'])) {
|
|
$label = __($context['translated_label']);
|
|
$tid = $context['tid'] ?? null;
|
|
$code = $context['raw_code'] ?? '0000';
|
|
|
|
if ($tid) {
|
|
return __('Slot') . " {$tid}: {$label} (Code: {$code})";
|
|
}
|
|
return "{$label} (Code: {$code})";
|
|
}
|
|
|
|
// 預設退回原始 message (支援歷史資料的翻譯判定與佔位符替換)
|
|
return __($this->message, $context ?? []);
|
|
}
|
|
|
|
public function machine()
|
|
{
|
|
return $this->belongsTo(Machine::class);
|
|
}
|
|
}
|