Completed
Push — master ( d778e6...6d1c30 )
by ARCANEDEV
08:16
created

Permission   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 3
c 4
b 0
f 0
lcom 1
cbo 2
dl 0
loc 50
ccs 0
cts 7
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A firstHashedOrFail() 0 4 1
A getIds() 0 4 1
A hasGroup() 0 4 1
1
<?php namespace Arcanesoft\Auth\Models;
2
3
use Arcanedev\LaravelAuth\Models\Permission as BasePermissionModel;
4
5
/**
6
 * Class     Permission
7
 *
8
 * @package  Arcanesoft\Auth\Models
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class Permission extends BasePermissionModel
12
{
13
    /* ------------------------------------------------------------------------------------------------
14
     |  Traits
15
     | ------------------------------------------------------------------------------------------------
16
     */
17
    use Presenters\PermissionPresenter;
18
19
    /* ------------------------------------------------------------------------------------------------
20
     |  Main Function
21
     | ------------------------------------------------------------------------------------------------
22
     */
23
    /**
24
     * Get a permission from a hashed id or fail if not found.
25
     *
26
     * @param  string  $hashedId
27
     *
28
     * @return self
29
     *
30
     * @throws \Illuminate\Database\Eloquent\ModelNotFoundException
31
     */
32
    public static function firstHashedOrFail($hashedId)
33
    {
34
        return self::withHashedId($hashedId)->firstOrFail();
35
    }
36
37
    /**
38
     * Get the ids of all permissions.
39
     *
40
     * @return \Illuminate\Database\Eloquent\Collection
41
     */
42
    public static function getIds()
43
    {
44
        return self::orderBy('id')->pluck('id');
45
    }
46
47
    /* ------------------------------------------------------------------------------------------------
48
     |  Check Functions
49
     | ------------------------------------------------------------------------------------------------
50
     */
51
    /**
52
     * Check if permission has a group.
53
     *
54
     * @return bool
55
     */
56
    public function hasGroup()
57
    {
58
        return $this->group_id !== 0;
59
    }
60
}
61