NoticeTemplate.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace app\admin\model\notice;
  3. use think\Model;
  4. class NoticeTemplate extends Model
  5. {
  6. // 表名
  7. protected $name = 'notice_template';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. ];
  17. public function getVisibleSwitchList()
  18. {
  19. return ['0' => __('Visible_switch 0'), '1' => __('Visible_switch 1')];
  20. }
  21. public function getVisibleSwitchTextAttr($value, $data)
  22. {
  23. $value = $value ? $value : (isset($data['visible_switch']) ? $data['visible_switch'] : '');
  24. $list = $this->getVisibleSwitchList();
  25. return isset($list[$value]) ? $list[$value] : '';
  26. }
  27. public function noticeevent()
  28. {
  29. return $this->belongsTo('NoticeEvent', 'notice_event_id', 'id', [], 'LEFT')->setEagerlyType(0);
  30. }
  31. public function getUrlTypeList()
  32. {
  33. $type = $this['type'] ?? '';
  34. if ($type == 'msg') {
  35. return [1 => '链接', 2=>'弹窗', 3=>'新窗口'];
  36. }
  37. if ($type == 'mptemplate') {
  38. return [1 => '链接'];
  39. }
  40. return [1 => '链接', 2=>'弹窗', 3=>'新窗口'];
  41. }
  42. }