Completed
Push — master ( df6768...08ae01 )
by Fèvre
11:28 queued 02:11
created

PermissionRepository::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

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 4
nc 1
nop 1
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\Permission;
7
8
class PermissionRepository
9
{
10
    /**
11
     * Create a new permission instance.
12
     *
13
     * @param array $data The data used to create the permission.
14
     *
15
     * @return \Xetaravel\Models\Permission
16
     */
17
    public static function create(array $data): Permission
18
    {
19
        return Permission::create([
20
            'name' => $data['name'],
21
            'description' => $data['description']
22
        ]);
23
    }
24
25
    /**
26
     * Update the permission informations after a valid update request.
27
     *
28
     * @param array $data The data used to update the permission.
29
     * @param \Xetaravel\Models\Permission $permission The permission to update.
30
     *
31
     * @return bool
32
     */
33
    public static function update(array $data, Permission $permission): bool
34
    {
35
        $permission->name = $data['name'];
36
        $permission->description = $data['description'];
37
38
        return $permission->save();
39
    }
40
}
41