Passed
Push — chore/add-feature-tests ( 36c2df...e56562 )
by Bas
04:12 queued 19s
created

Location   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
c 0
b 0
f 0
dl 0
loc 49
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A tags() 0 4 1
A inhabitants() 0 3 1
A leader() 0 3 1
A character() 0 3 1
A capturable() 0 3 1
1
<?php
2
3
namespace TestSetup\Models;
4
5
use Illuminate\Database\Eloquent\Relations\HasMany;
6
use LaravelFreelancerNL\Aranguent\Eloquent\Model;
7
8
class Location extends Model
9
{
10
    protected $table = 'locations';
11
12
    protected $fillable = [
13
        'id',
14
        'name',
15
        'coordinate',
16
        'led_by',
17
        'capturable_id',
18
        'capturable_type',
19
    ];
20
21
    /**
22
     * Get the last known residence of the character.
23
     */
24
    public function character()
25
    {
26
        return $this->hasOne(Character::class);
27
    }
28
29
    /**
30
     * Get the last known residence of the character.
31
     */
32
    public function leader()
33
    {
34
        return $this->belongsTo(Character::class, 'led_by');
35
    }
36
37
    /**
38
     * @return HasMany
39
     */
40
    public function inhabitants()
41
    {
42
        return $this->hasMany(Character::class, 'residence_id');
43
    }
44
45
    public function capturable()
46
    {
47
        return $this->morphTo();
48
    }
49
50
    /**
51
     * Get all of the tags for the post.
52
     */
53
    public function tags()
54
    {
55
        return $this->morphToMany(Tag::class, 'taggable')
56
            ->using(Taggable::class);
57
    }
58
}
59