mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 20:40:49 +08:00
improve exam trans
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\User\ExamUserResource\Pages;
|
||||
|
||||
use App\Filament\Resources\User\ExamUserResource;
|
||||
use App\Models\Exam;
|
||||
use App\Repositories\ExamRepository;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Pages\Actions;
|
||||
@@ -62,8 +63,12 @@ class ViewExamUser extends ViewRecord
|
||||
|
||||
protected function getViewData(): array
|
||||
{
|
||||
/** @var Exam $exam */
|
||||
$exam = $this->record->exam;
|
||||
return [
|
||||
'cardData' => $this->getDetailCardData(),
|
||||
'result_pass_trans_key' => $exam->getPassResultTransKey('pass'),
|
||||
'result_not_pass_trans_key' => $exam->getPassResultTransKey('not_pass'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -275,6 +275,15 @@ class Exam extends NexusModel
|
||||
};
|
||||
}
|
||||
|
||||
public function getPassResultTransKey(string $result): string
|
||||
{
|
||||
return match ($this->type) {
|
||||
self::TYPE_EXAM => "exam.result_{$result}_for_exam",
|
||||
self::TYPE_TASK => "exam.result_{$result}_for_task",
|
||||
default => throw new \RuntimeException("Invalid type: " . $this->type)
|
||||
};
|
||||
}
|
||||
|
||||
public function isTypeExam(): bool
|
||||
{
|
||||
return $this->type == self::TYPE_EXAM;
|
||||
|
||||
Reference in New Issue
Block a user