SystemPermLog.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\admin\model;
  3. use support\Model;
  4. /**
  5. * 悦享家会员套餐包记录模型
  6. * Class SystemPermLog
  7. * @package app\admin\model
  8. */
  9. class SystemPermLog extends Model
  10. {
  11. /**
  12. * The table associated with the model.
  13. *
  14. * @var string
  15. */
  16. protected $table = 'system_perm_log';
  17. /**
  18. * Notes:获取日志列表
  19. * @param string $keywords
  20. * @param int $page
  21. * @param int $limit
  22. * @return array
  23. * User: YCP
  24. * Date: 2022/11/22
  25. */
  26. public static function getLogList(int $page, int $limit,$keywords)
  27. {
  28. $list = static::select('*')
  29. ->when($keywords != '', function ($query) use ($keywords){
  30. $query->where('log_name', 'like', '%' . $keywords . '%');
  31. })
  32. ->orderBy('log_create_time','DESC')
  33. ->forPage($page, $limit)
  34. ->get();
  35. $count = static::when($keywords != '', function ($query) use ($keywords){
  36. $query->where('log_name', 'like', '%' . $keywords . '%');
  37. })
  38. ->count();
  39. return [$list, $count];
  40. }
  41. //时间格式
  42. public function getLogCreateTimeAttribute($value)
  43. {
  44. if($value == 0 || $value == ''){
  45. return 0;
  46. }else{
  47. return date('Y-m-d H:i:s', $value);
  48. }
  49. }
  50. }