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

Location::capturable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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