@@ 71-75 (lines=5) @@ | ||
68 | $this->authorize('create_role'); |
|
69 | ||
70 | $role = Roles::create($request->all()); |
|
71 | if (!empty($request->permission) AND is_array($request->permission)) { |
|
72 | foreach ($request->permission as $permission) { |
|
73 | $role->permissions()->attach($permission); |
|
74 | } |
|
75 | } |
|
76 | $request->session()->flash('message', 'Role Successfully Created'); |
|
77 | return redirect()->route('RoleManager::role.edit', $role->id); |
|
78 | } |
|
@@ 114-119 (lines=6) @@ | ||
111 | ||
112 | $role = Roles::where('id', $id)->firstOrFail(); |
|
113 | $role->update($request->all()); |
|
114 | if (!empty($request->permission) AND is_array($request->permission)) { |
|
115 | $role->permissions()->sync($request->permission); |
|
116 | ||
117 | } else { |
|
118 | $role->permissions()->detach(); |
|
119 | } |
|
120 | $request->session()->flash('message', 'Role Updated Successfully'); |
|
121 | return redirect()->route('RoleManager::role.edit', $role->id); |
|
122 | } |