Passed
Push — next ( bbb9c5...d20d04 )
by Bas
07:19 queued 03:59
created

Character::captured()   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 LaravelFreelancerNL\Aranguent\Eloquent\Model;
6
7
class Character extends Model
8
{
9
    protected $table = 'characters';
10
11
    /**
12
     * All of the relationships to be touched.
13
     *
14
     * @var array
15
     */
16
    protected $touches = ['location'];
17
18
    protected $fillable = [
19
        'id',
20
        'name',
21
        'surname',
22
        'alive',
23
        'age',
24
        'en',
25
        'de',
26
        'nl',
27
        'traits',
28
        'location_id',
29
        'residence_id',
30
    ];
31
32
    /**
33
     * Get the last known residence of the character.
34
     */
35
    public function location()
36
    {
37
        return $this->belongsTo(Location::class);
38
    }
39
40
    public function leads()
41
    {
42
        return $this->hasOne(Location::class, 'led_by');
43
    }
44
45
    public function residence()
46
    {
47
        return $this->belongsTo(Location::class, 'residence_id');
48
    }
49
50
    public function parents()
51
    {
52
        return $this->belongsToMany(
53
            Character::class,
54
            'children',
55
            '_to',
56
            '_from',
57
            '_id',
58
            '_id',
59
        );
60
    }
61
62
    public function children()
63
    {
64
        return $this->belongsToMany(
65
            Character::class,
66
            'children',
67
            '_from',
68
            '_to',
69
            '_id',
70
            '_id',
71
        )->using('TestSetup\Models\Child')
72
            ->withPivot([
73
                'created_by',
74
                'updated_by',
75
            ]);
76
    }
77
78
    public function captured()
79
    {
80
        return $this->morphMany(Location::class, 'capturable');
81
    }
82
83
    public function conquered()
84
    {
85
        return $this->morphOne(Location::class, 'capturable');
86
    }
87
88
    /**
89
     * Get all of the tags for the post.
90
     */
91
    public function tags()
92
    {
93
        return $this->morphToMany(Tag::class, 'taggable')
94
            ->using(Taggable::class);
95
    }
96
}
97