SystemLog.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\model\system\log;
  12. use crmeb\basic\BaseModel;
  13. use crmeb\traits\ModelTrait;
  14. use think\Model;
  15. /**
  16. * 日志模型
  17. * Class SystemLog
  18. * @package app\model\system\log
  19. */
  20. class SystemLog extends BaseModel
  21. {
  22. use ModelTrait;
  23. /**
  24. * 数据表主键
  25. * @var string
  26. */
  27. protected $pk = 'id';
  28. /**
  29. * 模型名称
  30. * @var string
  31. */
  32. protected $name = 'system_log';
  33. protected $insert = ['add_time'];
  34. protected function setAddTimeAttr()
  35. {
  36. return time();
  37. }
  38. /**
  39. * @param $query
  40. * @param $value
  41. */
  42. public function searchStoreIdAttr($query, $value)
  43. {
  44. if ($value !== '') $query->where('store_id', $value);
  45. }
  46. /**
  47. * 访问方式搜索器
  48. * @param Model $query
  49. * @param $value
  50. */
  51. public function searchPagesAttr($query, $value)
  52. {
  53. $query->whereLike('page', '%' . $value . '%');
  54. }
  55. /**
  56. * 访问路径搜索器
  57. * @param Model $query
  58. * @param $value
  59. */
  60. public function searchPathAttr($query, $value)
  61. {
  62. $query->whereLike('path', '%' . $value . '%');
  63. }
  64. /**
  65. * ip搜索器
  66. * @param Model $query
  67. * @param $value
  68. */
  69. public function searchIpAttr($query, $value)
  70. {
  71. $query->where('ip', 'LIKE', "%$value%");
  72. }
  73. /**
  74. * 管理员id搜索器
  75. * @param Model $query
  76. * @param $value
  77. */
  78. public function searchAdminIdAttr($query, $value)
  79. {
  80. $query->whereIn('admin_id', $value);
  81. }
  82. }