ServerService.php 757 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace App\Services;
  3. use App\Models\User;
  4. class ServerService
  5. {
  6. public function getAvailableUsers($groupId)
  7. {
  8. return User::whereIn('group_id', $groupId)
  9. ->whereRaw('u + d < transfer_enable')
  10. ->where(function ($query) {
  11. $query->where('expired_at', '>=', time())
  12. ->orWhere('expired_at', 0);
  13. })
  14. ->where('enable', 1)
  15. ->select([
  16. 'id',
  17. 'email',
  18. 't',
  19. 'u',
  20. 'd',
  21. 'transfer_enable',
  22. 'enable',
  23. 'v2ray_uuid',
  24. 'v2ray_alter_id',
  25. 'v2ray_level'
  26. ])
  27. ->get();
  28. }
  29. }