AdminLoginLogModel.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * AdminLoginLogModel.php UTF-8
  4. * 管理员登陆日志
  5. *
  6. * @date : 2018/3/2 15:21
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : linjiebin <ljb@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huo\model\user;
  13. use think\Model;
  14. class AdminLoginLogModel extends Model {
  15. protected $name = 'admin_login_log';
  16. public function __construct($data = []) {
  17. parent::__construct($data);
  18. }
  19. /**
  20. * 用户表
  21. *
  22. * @return \think\model\relation\HasOne
  23. */
  24. public function user() {
  25. return $this->belongsTo('huo\model\user\UserModel', 'user_id', 'id', [], 'left')->field('id,user_login')
  26. ->setEagerlyType(0);
  27. }
  28. /**
  29. * 登录记录
  30. *
  31. * @param array $map
  32. * @param int $offset
  33. *
  34. * @return bool|\think\Paginator
  35. * @throws \think\exception\DbException
  36. */
  37. public function userLoginInfo($map = [], $offset = 10) {
  38. $_data = $this
  39. ->with('user')
  40. ->where($map)
  41. ->order('id desc')
  42. ->paginate($offset);
  43. return $_data;
  44. }
  45. /**
  46. * 插入记录
  47. *
  48. * @param $data
  49. *
  50. * @return bool|int|string
  51. */
  52. public function addLog($data) {
  53. $_res = $this->insert($data);
  54. if ($_res !== false) {
  55. return true;
  56. }
  57. return $_res;
  58. }
  59. }