Completed
Push — master ( 91f8d9...64265e )
by Mohamed
09:45 queued 06:57
created

QueryTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 2
c 2
b 1
f 0
lcom 0
cbo 1
dl 0
loc 26
ccs 0
cts 5
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTagsExcept() 0 4 1
A getTagsExceptStatus() 0 6 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\Project\Issue;
13
14
use Illuminate\Database\Eloquent;
15
use Illuminate\Database\Eloquent\Relations;
16
use Tinyissue\Model\Tag;
17
18
/**
19
 * QueryTrait is trait class containing the database queries methods for the Project|Issue model.
20
 *
21
 * @author Mohamed Alsharaf <[email protected]>
22
 *
23
 * @method Relations\BelongsToMany tags()
24
 */
25
trait QueryTrait
26
{
27
    /**
28
     * Returns issue tags except for the status tags.
29
     *
30
     * @return Eloquent\Collection
31
     */
32
    public function getTagsExceptStatus()
33
    {
34
        $statusGroup = Tag::where('name', '=', Tag::GROUP_STATUS)->first();
35
36
        return $this->tags()->where('parent_id', '!=', $statusGroup->id);
37
    }
38
39
    /**
40
     * Returns issue tags except for a specific tag.
41
     *
42
     * @param string $tag
43
     *
44
     * @return Eloquent\Collection
45
     */
46
    public function getTagsExcept($tag)
47
    {
48
        return $this->tags()->where('name', '!=', $tag);
49
    }
50
}
51