123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- namespace App\Services\Client;
- use App\Models\CoachUser;
- use App\Models\MemberUser;
- use Illuminate\Support\Facades\Auth;
- use Illuminate\Support\Facades\DB;
- class TeamService
- {
- /**
- * 获取团队列表
- */
- public function getTeamList()
- {
- // 获取当前用户
- $userId = Auth::id();
- $user = MemberUser::findOrFail($userId);
-
- // 检查用户状态
- if ($user->state !== 'enable') {
- throw new \Exception('用户状态异常');
- }
-
- // 获取下级用户列表
- $teamList = MemberUser::where('parent_id', $userId)
- ->where('state', 'enable')
- ->with(['coachUser']) // 关联技师信息
- ->orderBy('created_at', 'desc')
- ->paginate(10);
-
- return $teamList;
- }
- }
|