LeaderboardScore::player()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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
}