LeaderboardScore   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 28
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A player() 0 3 1
A timescope() 0 3 1
A find() 0 3 1
A getNameAttribute() 0 6 2
1
<?php
2
3
namespace Furic\Leaderboards\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Furic\GameEssentials\Models\Player;
7
8
class LeaderboardScore extends Model
9
{
10
11
    protected $guarded = [];
12
    protected $hidden = ['leaderboard_timescope_id', 'player', 'created_at', 'updated_at'];
13
    protected $appends = ['name'];
14
15
    public static function find($leaderbarodTimescopeId, $playerId)
16
    {
17
        return SELF::where('leaderboard_timescope_id', $leaderbarodTimescopeId)->where('player_id', $playerId)->first();
18
    }
19
    
20
    public function timescope()
21
    {
22
        return $this->belongsTo(LeaderboardTimescope::class);
23
    }
24
25
    public function player()
26
    {
27
        return $this->belongsTo(Player::class);
28
    }
29
30
    public function getNameAttribute()
31
    {
32
        if ($this->player != null) {
33
            return $this->player->name;
34
        }
35
        return NULL;
36
        // return $this->player()->firstOrFail()->name;
37
    }
38
    
39
}