mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 12:07:23 +08:00
task claimed count on going
This commit is contained in:
+1
-1
@@ -299,7 +299,7 @@ class Exam extends NexusModel
|
|||||||
return $this->belongsToMany(User::class, "exam_users", "exam_id", "uid");
|
return $this->belongsToMany(User::class, "exam_users", "exam_id", "uid");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function OnGoingUsers()
|
public function onGoingUsers()
|
||||||
{
|
{
|
||||||
return $this->users()->wherePivot("status", ExamUser::STATUS_NORMAL);
|
return $this->users()->wherePivot("status", ExamUser::STATUS_NORMAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -392,7 +392,7 @@ class ExamRepository extends BaseRepository
|
|||||||
throw new NexusException(nexus_trans('exam.claim_by_yourself_only', [], $locale));
|
throw new NexusException(nexus_trans('exam.claim_by_yourself_only', [], $locale));
|
||||||
}
|
}
|
||||||
if ($exam->max_user_count > 0) {
|
if ($exam->max_user_count > 0) {
|
||||||
$claimUserCount = ExamUser::query()->where("exam_id", $examId)->count();
|
$claimUserCount = $exam->onGoingUsers()->count();
|
||||||
if ($claimUserCount >= $exam->max_user_count) {
|
if ($claimUserCount >= $exam->max_user_count) {
|
||||||
throw new NexusException(nexus_trans('exam.reach_max_user_count', [], $locale));
|
throw new NexusException(nexus_trans('exam.reach_max_user_count', [], $locale));
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -9,7 +9,7 @@ $query = \App\Models\Exam::query()
|
|||||||
$total = (clone $query)->count();
|
$total = (clone $query)->count();
|
||||||
$perPage = 20;
|
$perPage = 20;
|
||||||
list($paginationTop, $paginationBottom, $limit, $offset) = pager($perPage, $total, "?");
|
list($paginationTop, $paginationBottom, $limit, $offset) = pager($perPage, $total, "?");
|
||||||
$rows = (clone $query)->offset($offset)->take($perPage)->orderBy('id', 'desc')->withCount("users")->get();
|
$rows = (clone $query)->offset($offset)->take($perPage)->orderBy('id', 'desc')->withCount("onGoingUsers")->get();
|
||||||
$title = nexus_trans('exam.type_task');
|
$title = nexus_trans('exam.type_task');
|
||||||
$columnNameLabel = nexus_trans('label.name');
|
$columnNameLabel = nexus_trans('label.name');
|
||||||
$columnIndexLabel = nexus_trans('exam.index');
|
$columnIndexLabel = nexus_trans('exam.index');
|
||||||
@@ -75,7 +75,7 @@ foreach ($rows as $row) {
|
|||||||
$columns[] = sprintf('<td>%s</td>', $row->filterFormatted);
|
$columns[] = sprintf('<td>%s</td>', $row->filterFormatted);
|
||||||
$columns[] = sprintf('<td>%s</td>', number_format($row->success_reward_bonus));
|
$columns[] = sprintf('<td>%s</td>', number_format($row->success_reward_bonus));
|
||||||
$columns[] = sprintf('<td>%s</td>', number_format($row->fail_deduct_bonus));
|
$columns[] = sprintf('<td>%s</td>', number_format($row->fail_deduct_bonus));
|
||||||
$columns[] = sprintf('<td>%s</td>', sprintf("%s/%s",$row->users_count, $row->max_user_count ?: nexus_trans("label.infinite")));
|
$columns[] = sprintf('<td>%s</td>', sprintf("%s/%s",$row->on_going_users_count ?? 0, $row->max_user_count ?: nexus_trans("label.infinite")));
|
||||||
$columns[] = sprintf('<td>%s</td>', $row->description);
|
$columns[] = sprintf('<td>%s</td>', $row->description);
|
||||||
$columns[] = sprintf('<td>%s</td>', $claimAction);
|
$columns[] = sprintf('<td>%s</td>', $claimAction);
|
||||||
$table .= sprintf('<tr>%s</tr>', implode("", $columns));
|
$table .= sprintf('<tr>%s</tr>', implode("", $columns));
|
||||||
|
|||||||
Reference in New Issue
Block a user