SentryRoleRepository::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 5
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
1
<?php namespace Modules\User\Repositories\Sentry;
2
3
use Cartalyst\Sentry\Facades\Laravel\Sentry;
4
use Modules\User\Repositories\RoleRepository;
5
6
class SentryRoleRepository implements RoleRepository
7
{
8
    /**
9
     * Return all the roles
10
     * @return mixed
11
     */
12
    public function all()
13
    {
14
        return Sentry::findAllGroups();
15
    }
16
17
    /**
18
     * Create a role resource
19
     * @return mixed
20
     */
21
    public function create($data)
22
    {
23
        unset($data['slug']);
24
        Sentry::createGroup($data);
25
    }
26
27
    /**
28
     * Find a role by its id
29
     * @param $id
30
     * @return mixed
31
     */
32
    public function find($id)
33
    {
34
        return Sentry::findGroupById($id);
35
    }
36
37
    /**
38
     * Update a role
39
     * @param $id
40
     * @param $data
41
     * @return mixed
42
     */
43
    public function update($id, $data)
44
    {
45
        unset($data['slug']);
46
        $role = Sentry::findGroupById($id);
47
48
        $role->update($data);
49
    }
50
51
    /**
52
     * Delete a role
53
     * @param $id
54
     * @return mixed
55
     */
56
    public function delete($id)
57
    {
58
        $role = Sentry::findGroupById($id);
59
60
        return $role->delete();
61
    }
62
63
    /**
64
     * Find a role by its name
65
     * @param  string $name
66
     * @return mixed
67
     */
68
    public function findByName($name)
69
    {
70
        return Sentry::findGroupByName($name);
71
    }
72
}
73