Files
nexusphp/app/Models/Exam.php

50 lines
1.4 KiB
PHP
Raw Normal View History

2021-04-19 20:13:21 +08:00
<?php
namespace App\Models;
class Exam extends NexusModel
{
2021-04-23 20:05:39 +08:00
protected $fillable = ['name', 'description', 'begin', 'end', 'status', 'filters', 'indexes'];
2021-04-25 02:12:14 +08:00
public $timestamps = true;
2021-04-23 20:05:39 +08:00
protected $casts = [
'filters' => 'object',
'indexes' => 'array',
];
2021-04-20 20:18:02 +08:00
const STATUS_ENABLED = 0;
const STATUS_DISABLED = 1;
public static $status = [
2021-04-23 20:05:39 +08:00
self::STATUS_ENABLED => ['text' => 'Enabled'],
self::STATUS_DISABLED => ['text' => 'Disabled'],
2021-04-20 20:18:02 +08:00
];
const INDEX_UPLOADED = 1;
const INDEX_SEED_TIME_AVERAGE = 2;
2021-04-20 20:18:02 +08:00
const INDEX_DOWNLOADED = 3;
2021-04-23 20:05:39 +08:00
const INDEX_BONUS = 4;
2021-04-20 20:18:02 +08:00
public static $indexes = [
2021-04-23 20:05:39 +08:00
self::INDEX_UPLOADED => ['name' => 'Uploaded', 'unit' => 'GB'],
self::INDEX_SEED_TIME_AVERAGE => ['name' => 'Seed Time Average', 'unit' => 'Hour'],
2021-04-23 20:05:39 +08:00
self::INDEX_DOWNLOADED => ['name' => 'Downloaded', 'unit' => 'GB'],
self::INDEX_BONUS => ['name' => 'Bonus', 'unit' => ''],
];
const FILTER_USER_CLASS = 'classes';
const FILTER_USER_REGISTER_TIME_RANGE = 'register_time_range';
public static $filters = [
self::FILTER_USER_CLASS => ['name' => 'User Class'],
self::FILTER_USER_REGISTER_TIME_RANGE => ['name' => 'User Register Time Range'],
2021-04-20 20:18:02 +08:00
];
public function getStatusTextAttribute(): string
2021-04-20 20:18:02 +08:00
{
return self::$status[$this->status]['text'] ?? '';
}
2021-04-19 20:13:21 +08:00
}