exam add max user count

This commit is contained in:
xiaomlove
2024-08-08 03:14:34 +08:00
parent eae609e927
commit 6894508d81
9 changed files with 110 additions and 38 deletions

View File

@@ -11,7 +11,7 @@ class Exam extends NexusModel
{
protected $fillable = [
'name', 'description', 'begin', 'end', 'duration', 'status', 'is_discovered', 'filters', 'indexes', 'priority',
'recurring', 'type', 'success_reward_bonus', 'fail_deduct_bonus'
'recurring', 'type', 'success_reward_bonus', 'fail_deduct_bonus', 'max_user_count'
];
public $timestamps = true;
@@ -294,4 +294,14 @@ class Exam extends NexusModel
return $this->type == self::TYPE_TASK;
}
public function users()
{
return $this->belongsToMany(User::class, "exam_users", "exam_id", "uid");
}
public function OnGoingUsers()
{
return $this->users()->wherePivot("status", ExamUser::STATUS_NORMAL);
}
}