GroupMember::getGuildAttribute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace App\Models;
4
5
/**
6
 * Class GroupMember.
7
 */
8
class GroupMember extends ChocolateyModel
9
{
10
    /**
11
     * Disable Timestamps.
12
     *
13
     * @var bool
14
     */
15
    public $timestamps = false;
16
17
    /**
18
     * The table associated with the model.
19
     *
20
     * @var string
21
     */
22
    protected $table = 'guilds_members';
23
24
    /**
25
     * Primary Key of the Table.
26
     *
27
     * @var string
28
     */
29
    protected $primaryKey = 'id';
30
31
    /**
32
     * The attributes excluded from the model's JSON form.
33
     *
34
     * @var array
35
     */
36
    protected $hidden = ['id', 'member_since', 'guild_id', 'level_id', 'user_id'];
37
38
    /**
39
     * The Appender(s) of the Model.
40
     *
41
     * @var array
42
     */
43
    protected $appends = ['guild'];
44
45
    /**
46
     * Get User Group by Member Group Id.
47
     *
48
     * @return UserGroup
49
     */
50
    public function getGuildAttribute(): UserGroup
51
    {
52
        return UserGroup::find($this->attributes['guild_id']);
53
    }
54
55
    /**
56
     * Get Description Attribute.
57
     *
58
     * @TODO: Get Real Badge Description
59
     *
60
     * @return string
61
     */
62
    public function getDescriptionAttribute(): string
63
    {
64
        return "Badge {$this->attributes['badge_code']}";
65
    }
66
}
67