SystemLog.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 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. * 访问方式搜索器
  40. * @param Model $query
  41. * @param $value
  42. */
  43. public function searchPagesAttr($query, $value)
  44. {
  45. if ($value !== '') {
  46. $query->whereLike('page', '%' . $value . '%');
  47. }
  48. }
  49. /**
  50. * 访问路径搜索器
  51. * @param Model $query
  52. * @param $value
  53. */
  54. public function searchPathAttr($query, $value)
  55. {
  56. if ($value !== '') {
  57. $query->whereLike('path', '%' . $value . '%');
  58. }
  59. }
  60. /**
  61. * ip搜索器
  62. * @param Model $query
  63. * @param $value
  64. */
  65. public function searchIpAttr($query, $value)
  66. {
  67. if ($value !== '') {
  68. $query->where('ip', 'LIKE', "%$value%");
  69. }
  70. }
  71. /**
  72. * 管理员id搜索器
  73. * @param Model $query
  74. * @param $value
  75. */
  76. public function searchAdminIdAttr($query, $value)
  77. {
  78. if (!empty($value)) {
  79. $query->whereIn('admin_id', $value);
  80. }
  81. }
  82. }