Printer.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2024 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\common\model;
  13. use cores\BaseModel;
  14. use app\common\library\helper;
  15. /**
  16. * 小票打印机模型
  17. * Class Printer
  18. * @package app\common\model
  19. */
  20. class Printer extends BaseModel
  21. {
  22. // 定义表名
  23. protected $name = 'printer';
  24. // 定义主键
  25. protected $pk = 'printer_id';
  26. /**
  27. * 自动转换printer_config为array格式
  28. * @param $value
  29. * @return array
  30. */
  31. public function getPrinterConfigAttr($value): array
  32. {
  33. return helper::jsonDecode($value);
  34. }
  35. /**
  36. * 自动转换printer_config为json格式
  37. * @param $value
  38. * @return string
  39. */
  40. public function setPrinterConfigAttr($value): string
  41. {
  42. return helper::jsonEncode($value);
  43. }
  44. /**
  45. * 打印机详情
  46. * @param int $printerId
  47. * @return static|array|null
  48. */
  49. public static function detail(int $printerId)
  50. {
  51. return self::get($printerId);
  52. }
  53. }