Permission::hasGroup()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php namespace Arcanesoft\Auth\Models;
2
3
use Arcanedev\LaravelAuth\Models\Permission as BasePermission;
4
5
/**
6
 * Class     Permission
7
 *
8
 * @package  Arcanesoft\Auth\Models
9
 * @author   ARCANEDEV <[email protected]>
10
 *
11
 * @property  int|null  roles_count
12
 *
13
 * @mixin  \Illuminate\Database\Eloquent\Builder
14
 */
15
class Permission extends BasePermission
16
{
17
    /* -----------------------------------------------------------------
18
     |  Traits
19
     | -----------------------------------------------------------------
20
     */
21
22
    use Presenters\PermissionPresenter;
23
24
    /* -----------------------------------------------------------------
25
     |  Main Methods
26
     | -----------------------------------------------------------------
27
     */
28
29
    /**
30
     * Get a permission from a hashed id or fail if not found.
31
     *
32
     * @param  string  $hashedId
33
     *
34
     * @return self
35
     *
36
     * @throws \Illuminate\Database\Eloquent\ModelNotFoundException
37
     */
38
    public static function firstHashedOrFail($hashedId)
39
    {
40
        return self::withHashedId($hashedId)->firstOrFail();
41
    }
42
43
    /**
44
     * Get the ids of all permissions.
45
     *
46
     * @return \Illuminate\Support\Collection
47
     */
48
    public static function getIds()
49
    {
50
        return self::query()->orderBy('id')->pluck('id');
0 ignored issues
show
Bug introduced by
The method orderBy() does not exist on Illuminate\Database\Eloquent\Builder. Did you maybe mean enforceOrderBy()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
51
    }
52
53
    /* -----------------------------------------------------------------
54
     |  Check Methods
55
     | -----------------------------------------------------------------
56
     */
57
58
    /**
59
     * Check if permission has a group.
60
     *
61
     * @return bool
62
     */
63
    public function hasGroup()
64
    {
65
        return $this->group_id > 0;
66
    }
67
}
68