|
@@ -467,12 +467,25 @@ class GameService
|
|
}
|
|
}
|
|
|
|
|
|
//待进行 比赛 (不包含用户已加入和创建的比赛)
|
|
//待进行 比赛 (不包含用户已加入和创建的比赛)
|
|
- public function getNotBeginGames()
|
|
|
|
|
|
+ public function getNotBeginGames($keyword)
|
|
{
|
|
{
|
|
|
|
+ $courseIds = [];
|
|
|
|
+ if($keyword = trim($keyword)){
|
|
|
|
+ $keyword = htmlspecialchars($keyword);
|
|
|
|
+ $courseIds = Course::query()
|
|
|
|
+ ->where('name', 'like', '%'.$keyword.'%')
|
|
|
|
+ ->whereNull('deleted_at')
|
|
|
|
+ ->pluck('id');
|
|
|
|
+ if($courseIds->isNotEmpty()){
|
|
|
|
+ $courseIds = $courseIds->toArray();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
//我相关的未开始比赛
|
|
//我相关的未开始比赛
|
|
$myGameIds = GameUser::query()
|
|
$myGameIds = GameUser::query()
|
|
->leftJoin('games', 'games.id', '=', 'game_users.game_id')
|
|
->leftJoin('games', 'games.id', '=', 'game_users.game_id')
|
|
->where('user_id', $this->user->id)
|
|
->where('user_id', $this->user->id)
|
|
|
|
+ ->where('type', 1)
|
|
->where('game_users.status', 1)
|
|
->where('game_users.status', 1)
|
|
->where('begin_time', '>', Carbon::now())
|
|
->where('begin_time', '>', Carbon::now())
|
|
->whereNull('game_users.deleted_at')
|
|
->whereNull('game_users.deleted_at')
|
|
@@ -488,6 +501,9 @@ class GameService
|
|
->where('begin_time', '>', Carbon::now())
|
|
->where('begin_time', '>', Carbon::now())
|
|
->whereColumn('scale', '>', 'members')
|
|
->whereColumn('scale', '>', 'members')
|
|
->whereNotIn('id', $myGameIds)
|
|
->whereNotIn('id', $myGameIds)
|
|
|
|
+ ->when($courseIds, function ($query, $courseIds){
|
|
|
|
+ $query->whereIn('course_id', $courseIds);
|
|
|
|
+ })
|
|
->orderBy('begin_time', 'asc')
|
|
->orderBy('begin_time', 'asc')
|
|
->pluck('id')
|
|
->pluck('id')
|
|
->toArray();
|
|
->toArray();
|