mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-23 19:37:23 +08:00
exam-user
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
class ExamUser extends NexusModel
|
||||
{
|
||||
protected $fillable = ['exam_id', 'uid', 'status', 'result'];
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
const STATUS_NORMAL = 0;
|
||||
const STATUS_FINISHED = 1;
|
||||
|
||||
public static $status = [
|
||||
self::STATUS_NORMAL => ['text' => 'Normal'],
|
||||
self::STATUS_FINISHED => ['text' => 'Finished'],
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'result' => 'json'
|
||||
];
|
||||
|
||||
public function getStatusTextAttribute()
|
||||
{
|
||||
return self::$status[$this->status]['text'] ?? '';
|
||||
}
|
||||
|
||||
public function exam(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Exam::class, 'exam_id');
|
||||
}
|
||||
|
||||
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'uid');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user