mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 20:40:49 +08:00
exam-user
This commit is contained in:
@@ -6,6 +6,8 @@ class AgentAllow extends NexusModel
|
||||
{
|
||||
protected $table = 'agent_allowed_family';
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
'family', 'start_name', 'exception', 'allowhttps', 'comment',
|
||||
'peer_id_pattern', 'peer_id_match_num', 'peer_id_matchtype', 'peer_id_start',
|
||||
|
||||
@@ -6,6 +6,8 @@ class Exam extends NexusModel
|
||||
{
|
||||
protected $fillable = ['name', 'description', 'begin', 'end', 'status', 'filters', 'indexes'];
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
protected $casts = [
|
||||
'filters' => 'object',
|
||||
'indexes' => 'array',
|
||||
|
||||
@@ -5,4 +5,6 @@ namespace App\Models;
|
||||
class ExamProgress extends NexusModel
|
||||
{
|
||||
protected $fillable = ['exam_id', 'uid', 'type_id', 'value'];
|
||||
|
||||
public $timestamps = true;
|
||||
}
|
||||
|
||||
39
app/Models/ExamUser.php
Normal file
39
app/Models/ExamUser.php
Normal file
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -11,6 +11,8 @@ class NexusModel extends Model
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $perPage = 2;
|
||||
|
||||
/**
|
||||
* 为数组 / JSON 序列化准备日期。
|
||||
*
|
||||
|
||||
@@ -54,6 +54,8 @@ class User extends Authenticatable
|
||||
self::CLASS_STAFF_LEADER => ['text' => 'Staff Leader'],
|
||||
];
|
||||
|
||||
protected $perPage = 2;
|
||||
|
||||
public function getClassTextAttribute(): string
|
||||
{
|
||||
return self::$classes[$this->class]['text'] ?? '';
|
||||
@@ -96,4 +98,21 @@ class User extends Authenticatable
|
||||
protected $casts = [
|
||||
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'added'
|
||||
];
|
||||
|
||||
|
||||
public function exams(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Exam::class, 'exam_users', 'uid', 'exam_id')->withTimestamps();
|
||||
}
|
||||
|
||||
public function examDetails(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(ExamUser::class. 'uid');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user