- ui_elements/ui_bundles/ui_bundle_items 三表 + Models(TenantScoped) - config/ui_parts.php 部位定義(Phase 1 啟用 A1/A2/A3 滿版) - UiElementController 三頁 CRUD + 圖片上傳(ImageHandler storeAsWebp) - 機台綁定存 machines.settings['ui_bundle_id'] - B014 getSettings 新增 UISet(部位→絕對圖URL,mirror B005) - 解除 sidebar APP管理 註解 + can:menu.app + 權限白名單 - zh_TW/en 翻譯 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
47 lines
933 B
PHP
47 lines
933 B
PHP
<?php
|
||
|
||
namespace App\Models\System;
|
||
|
||
use App\Traits\TenantScoped;
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||
use Illuminate\Database\Eloquent\Model;
|
||
|
||
class UiElement extends Model
|
||
{
|
||
use HasFactory, TenantScoped;
|
||
|
||
protected $fillable = [
|
||
'company_id',
|
||
'part_key',
|
||
'name',
|
||
'type',
|
||
'image_url',
|
||
'is_active',
|
||
];
|
||
|
||
protected $casts = [
|
||
'is_active' => 'boolean',
|
||
];
|
||
|
||
/**
|
||
* 部位定義(來自 config/ui_parts.php)。
|
||
*/
|
||
public function getPartAttribute(): ?array
|
||
{
|
||
return config("ui_parts.parts.{$this->part_key}");
|
||
}
|
||
|
||
/**
|
||
* 部位顯示名稱。
|
||
*/
|
||
public function getPartLabelAttribute(): string
|
||
{
|
||
return config("ui_parts.parts.{$this->part_key}.label", $this->part_key);
|
||
}
|
||
|
||
public function scopeActive($query)
|
||
{
|
||
return $query->where('is_active', true);
|
||
}
|
||
}
|