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

Permission::getHashedIdAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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