消息推送增加邮箱&&增加终版保存功能

This commit is contained in:
mzl
2025-09-15 15:01:19 +08:00
parent 3208fbd501
commit f152529364
14 changed files with 209 additions and 24 deletions
+28
View File
@@ -62,4 +62,32 @@ class SysDict extends Model
{
return $this->belongsTo(SysDictCategory::class, 'category_id', 'id');
}
/**
* 一个字典有多个字典项
*/
public function items()
{
return $this->hasMany(SysDictItem::class, 'dict_id', 'id');
}
/**
* 通过 dict_code 快速获取所有 item_value
*/
public function scopeGetItemValuesByCode($query, $dictCode)
{
return $query->where('dict_code', $dictCode)
->with('items') // 预加载关联项
->first()?->items->pluck('item_value'); // 返回 item_value 数组
}
/**
* 通过 dict_code 获取完整字典项(含 label + value)
*/
public function scopeGetItemsByCode($query, $dictCode)
{
return $query->where('dict_code', $dictCode)
->with('items')
->first()?->items;
}
}
+8
View File
@@ -56,4 +56,12 @@ class SysDictItem extends Model
{
return $this->belongsTo(SysDict::class, 'dict_id', 'id');
}
/**
* 字典项属于一个字典
*/
public function dict()
{
return $this->belongsTo(SysDict::class, 'dict_id', 'id');
}
}