RoutineTemplate.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * @author: xaboy<365615158@qq.com>
  4. * @day: 2017/11/02
  5. */
  6. namespace app\admin\model\routine;
  7. use crmeb\traits\ModelTrait;
  8. use crmeb\basic\BaseModel;
  9. /**
  10. * 小程序模板消息Model
  11. * Class RoutineTemplate
  12. * @package app\admin\model\wechat
  13. */
  14. class RoutineTemplate extends BaseModel
  15. {
  16. /**
  17. * 数据表主键
  18. * @var string
  19. */
  20. protected $pk = 'id';
  21. /**
  22. * 模型名称
  23. * @var string
  24. */
  25. protected $name = 'template_message';
  26. use ModelTrait;
  27. public static function vialdWhere(string $alias = '', int $type = 0)
  28. {
  29. if ($alias) {
  30. $alias .= '.';
  31. }
  32. return self::where($alias . 'type', $type);
  33. }
  34. /**
  35. * 获取系统分页数据 分类
  36. * @param array $where
  37. * @return array
  38. */
  39. public static function systemPage($where = array())
  40. {
  41. $model = self::vialdWhere();
  42. if ($where['name'] !== '') $model = $model->where('name', 'LIKE', "%$where[name]%");
  43. if ($where['status'] !== '') $model = $model->where('status', $where['status']);
  44. return self::page($model, $where);
  45. }
  46. /**
  47. * 根据模版编号获取模版ID
  48. * @param $tempkey
  49. */
  50. public static function getTempid($tempkey)
  51. {
  52. return self::vialdWhere()->where('tempkey', $tempkey)->where('status', 1)->cache(true, 3600)->value('tempid');
  53. }
  54. }