Completed
Pull Request — master (#16)
by Phecho
03:26
created

Group   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 2
c 2
b 0
f 1
lcom 0
cbo 2
dl 0
loc 28
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A scopeIsGroup() 0 4 1
A scopeMine() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of Gitamin.
5
 * 
6
 * Copyright (C) 2015-2016 The Gitamin Team
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 Gitamin\Models;
13
14
use Illuminate\Support\Facades\Auth;
15
use Illuminate\Database\Eloquent\Model;
16
17
class Group extends ProjectNamespace
18
{
19
    protected $table = 'namespaces';
20
21
    /**
22
     * Finds all groups.
23
     *
24
     * @param \Illuminate\Database\Eloquent\Builder $query
25
     *
26
     * @return \Illuminate\Database\Eloquent\Builder
27
     */
28
    public function scopeIsGroup($query)
29
    {
30
        return $query->where('type', 'group');
31
    }
32
33
    /**
34
     * Finds all my namespaces.
35
     *
36
     * @param \Illuminate\Database\Eloquent\Builder $query
37
     *
38
     * @return \Illuminate\Database\Eloquent\Builder
39
     */
40
    public function scopeMine($query)
41
    {
42
    	return $query->where('owner_id', Auth::user()->id);
43
    }
44
}
45