Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
RolesService
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 2
6
0.00% covered (danger)
0.00%
0 / 1
 insert
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
 update
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace App\Services;
4
5use App\Models\Role;
6use Illuminate\Support\Facades\Hash;
7
8class RolesService
9{
10    public function insert($request){
11        $role = Role::create([
12            'name'          => $request->name,
13            'display_name'  => $request->name,
14            'description'   => $request->description
15        ]);
16
17        //add permissions to this role
18        $role->attachPermissions($request->permissions);
19
20        return $role;
21    }
22
23    public function update($role, $request){
24        $role->name            = $request->name;
25        $role->display_name    = $request->name;
26        $role->description     = $request->description;
27        $role->save();
28
29        $role->syncPermissions($request->permissions); //update role permassion
30    }
31}