RelationTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 50%

Importance

Changes 2
Bugs 2 Features 0
Metric Value
wmc 4
c 2
b 2
f 0
lcom 0
cbo 0
dl 0
loc 46
ccs 4
cts 8
cp 0.5
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
belongsTo() 0 1 ?
hasMany() 0 1 ?
belongsToMany() 0 1 ?
A parent() 0 4 1
A tags() 0 4 1
A issues() 0 4 1
A projects() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Tinyissue package.
5
 *
6
 * (c) Mohamed Alsharaf <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Tinyissue\Model\Traits\Tag;
13
14
use Illuminate\Database\Eloquent\Relations;
15
16
/**
17
 * RelationTrait is trait class containing the relationship methods for the Tag model.
18
 *
19
 * @author Mohamed Alsharaf <[email protected]>
20
 *
21
 * @property static $this
22
 */
23
trait RelationTrait
24
{
25
    /**
26
     * Returns the parent/group for the tag.
27
     *
28
     * @return Relations\BelongsTo
29
     */
30 7
    public function parent()
31
    {
32 7
        return $this->belongsTo('Tinyissue\Model\Tag', 'parent_id');
33
    }
34
35
    /**
36
     * Parent tag/group have many tags.
37
     *
38
     * @return Relations\HasMany
39
     */
40 35
    public function tags()
41
    {
42 35
        return $this->hasMany('Tinyissue\Model\Tag', 'parent_id');
43
    }
44
45
    /**
46
     * Returns issues for the Tag. Tag can belong to many issues & issue can have many tags.
47
     *
48
     * @return Relations\BelongsToMany
49
     */
50
    public function issues()
51
    {
52
        return $this->belongsToMany('Tinyissue\Model\Project\Issue', 'projects_issues_tags', 'issue_id', 'tag_id');
53
    }
54
55
    /**
56
     * Returns projects for the Tag. Tag can belong to many projects & project can have many tags.
57
     *
58
     * @return Relations\BelongsToMany
59
     */
60
    public function projects()
61
    {
62
        return $this->belongsToMany('Tinyissue\Model\Project', 'projects_kanban_tags', 'project_id', 'tag_id');
63
    }
64
65
    abstract public function belongsTo($related, $foreignKey = null, $otherKey = null, $relation = null);
66
    abstract public function hasMany($related, $foreignKey = null, $localKey = null);
67
    abstract public function belongsToMany($related, $table = null, $foreignKey = null, $otherKey = null, $relation = null);
68
}
69