IntelligenceLog.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace app\admin\model;
  3. use support\Model;
  4. /**
  5. * 会员智能设备消息推送日志模型
  6. * Class Users
  7. * @package app\admin\model
  8. */
  9. class IntelligenceLog extends Model
  10. {
  11. /**
  12. * The table associated with the model.
  13. *
  14. * @var string
  15. */
  16. protected $table = 'user_intelligence_equipment_log';
  17. public $timestamps = false;
  18. /**
  19. * Notes:会员智能设备数据查询
  20. * @return int
  21. * User: ZQ
  22. * Date: 2022/9/19
  23. */
  24. public static function equipmentLogList(int $page,int $limit,$log_user_id, $log_equipment_id)
  25. {
  26. $list = static::select()
  27. ->when($log_user_id != '', function ($query) use ($log_user_id){
  28. $query->where('log_user_id', $log_user_id);
  29. })
  30. ->when($log_equipment_id != '', function ($query) use ($log_equipment_id){
  31. $query->where('log_equipment_id', $log_equipment_id);
  32. })
  33. ->forPage($page, $limit)
  34. ->orderBy('log_create_time','DESC')
  35. ->get();
  36. $count = static::select()
  37. ->when($log_user_id != '', function ($query) use ($log_user_id){
  38. $query->where('log_user_id', $log_user_id);
  39. })
  40. ->when($log_equipment_id != '', function ($query) use ($log_equipment_id){
  41. $query->where('log_equipment_id', $log_equipment_id);
  42. })
  43. ->count();
  44. return [$list,$count];
  45. }
  46. /**
  47. * Notes:会员智能设备数据详情
  48. * @return int
  49. * User: ZQ
  50. * Date: 2022/9/23
  51. */
  52. public static function logInfor(array $where)
  53. {
  54. return static::where($where)->first();
  55. }
  56. /**
  57. * Notes:智能设备数据插入
  58. * @return int
  59. * User: ZQ
  60. * Date: 2022/9/19
  61. */
  62. public static function logInsert($data)
  63. {
  64. $id = static::insertGetId($data);
  65. return $id;
  66. }
  67. }