Passed
Pull Request — master (#610)
by John
05:33
created

Judger   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 8
dl 0
loc 21
rs 10
c 1
b 0
f 1
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A column() 0 3 1
A oj() 0 2 1
A getReadableNameAttribute() 0 3 1
1
<?php
2
3
namespace App\Models\Eloquent;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Support\Facades\DB;
7
8
class Judger extends Model
9
{
10
    protected $table='judger';
11
    protected $primaryKey='jid';
12
13
    protected $fillable=[
14
        'oid', 'handle', 'password', 'available', 'using', 'user_id'
15
    ];
16
17
    public function getReadableNameAttribute()
18
    {
19
        return $this->handle.' @ '.$this->oj->name;
20
    }
21
22
    public static function column($key)
23
    {
24
        return Self::groupBy($key)->whereNotNull($key)->pluck($key)->toArray();
25
    }
26
27
    public function oj() {
28
        return $this->belongsTo('App\Models\Eloquent\OJ', 'oid', 'oid');
29
    }
30
}
31