Completed
Push — master ( cba711...9d321b )
by Phecho
06:37 queued 03:17
created

Group::scopeIsGroup()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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