You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SystemLog.php 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace app\model\system\log;
  3. use crmeb\basic\BaseModel;
  4. use crmeb\traits\ModelTrait;
  5. use think\Model;
  6. /**
  7. * 日志模型
  8. * Class SystemLog
  9. * @package app\model\system\log
  10. */
  11. class SystemLog extends BaseModel
  12. {
  13. use ModelTrait;
  14. /**
  15. * 数据表主键
  16. * @var string
  17. */
  18. protected $pk = 'id';
  19. /**
  20. * 模型名称
  21. * @var string
  22. */
  23. protected $name = 'system_log';
  24. protected $insert = ['add_time'];
  25. protected function setAddTimeAttr()
  26. {
  27. return time();
  28. }
  29. /**
  30. * @param $query
  31. * @param $value
  32. */
  33. public function searchStoreIdAttr($query, $value)
  34. {
  35. $query->where('store_id', $value);
  36. }
  37. /**
  38. * 访问方式搜索器
  39. * @param Model $query
  40. * @param $value
  41. */
  42. public function searchPagesAttr($query, $value)
  43. {
  44. $query->whereLike('page', '%' . $value . '%');
  45. }
  46. /**
  47. * 访问路径搜索器
  48. * @param Model $query
  49. * @param $value
  50. */
  51. public function searchPathAttr($query, $value)
  52. {
  53. $query->whereLike('path', '%' . $value . '%');
  54. }
  55. /**
  56. * ip搜索器
  57. * @param Model $query
  58. * @param $value
  59. */
  60. public function searchIpAttr($query, $value)
  61. {
  62. $query->where('ip', 'LIKE', "%$value%");
  63. }
  64. /**
  65. * 管理员id搜索器
  66. * @param Model $query
  67. * @param $value
  68. */
  69. public function searchAdminIdAttr($query, $value)
  70. {
  71. $query->whereIn('admin_id', $value);
  72. }
  73. }