Completed
Pull Request — master (#21)
by Fèvre
05:27 queued 02:44
created

RoleRepository::update()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 2
1
<?php
2
namespace Xetaravel\Models\Repositories;
3
4
use Illuminate\Support\Facades\Hash;
5
use Illuminate\Support\Facades\Request as FacadeRequest;
6
use Xetaravel\Models\Role;
7
8
class RoleRepository
9
{
10
    /**
11
     * Create a new user instance after a valid registration.
12
     *
13
     * @param array $data The data used to create the user.
14
     *
15
     * @return \Xetaravel\Models\User
16
     */
17
    public static function create(array $data): Role
18
    {
19
        return Role::create([
20
            'name' => $data['name'],
21
            'css' => $data['css'],
22
            'level' => $data['level'],
23
            'description' => $data['description']
24
        ]);
25
    }
26
27
    /**
28
     * Update the role informations after a valid update request.
29
     *
30
     * @param array $data The data used to update the user.
31
     * @param \Xetaravel\Models\Role $role The role to update.
32
     *
33
     * @return bool
34
     */
35
    public static function update(array $data, Role $role): bool
36
    {
37
        $role->name = $data['name'];
38
        $role->description = $data['description'];
39
        $role->css = $data['css'];
40
        $role->level = $data['level'];
41
42
        return $role->save();
43
    }
44
}
45