RolesRepository::getPublic()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace App\Repositories;
4
5
use Keyhunter\Administrator\Model\Role;
6
7
class RolesRepository extends Repository
8
{
9
    /**
10
     * Administrator.
11
     */
12
    const ADMIN = 'admin';
13
14
    /**
15
     * Simple user role.
16
     */
17
    const USER = 'member';
18
19
    /**
20
     * @return Role
21
     */
22
    public function getModel()
23
    {
24
        return new Role();
25
    }
26
27
    /**
28
     * Get administrator role.
29
     *
30
     * @return mixed
31
     */
32
    public function getAdminRole()
33
    {
34
        return self::getModel()
35
            ->whereName(self::ADMIN)
36
            ->first();
37
    }
38
39
    /**
40
     * Get simple user's role.
41
     *
42
     * @return mixed
43
     */
44
    public function getSimpleUserRole()
45
    {
46
        return self::getModel()
47
            ->whereName(self::USER)
48
            ->first();
49
    }
50
51
    /**
52
     * Get all active roles.
53
     *
54
     * @return mixed
55
     */
56
    public function getPublic()
57
    {
58
        return self::getModel()
59
            ->whereActive(1)
60
            ->orderBy('rank', 'ASC')
61
            ->get();
62
    }
63
}