예제 #1
0
 public function store_user_role(UserRoleRequest $request)
 {
     $data = ['name' => $request->get('role_name'), 'slug' => $request->get('role_slug'), 'description' => $request->get('role_description'), 'level' => $request->get('role_level')];
     $role = new Role($data);
     $role->save();
     $status = $request->get('role_slug') . " Role is created";
     return redirect('user/create_user_role')->with('status', $status);
 }
예제 #2
0
 public function update(UpdateRoleRequest $req, Role $role)
 {
     $role->name = $req->input('name');
     $role->save();
     $this->processPermissions($role);
     $message = 'تم تحديث بيانات المجموعة بنجاح';
     if (request('submit') == 'save') {
         return redirect()->back()->with('success', $message);
     }
     return redirect()->route('roles.index')->with('success', $message);
 }
예제 #3
0
 private function save(Role $role, array $inputs)
 {
     $role->name = ucfirst($inputs['name']);
     if (empty($inputs['slug'])) {
         $role->slug = Str::slug($inputs['name'], '.');
     } else {
         $role->slug = $inputs['slug'];
     }
     $role->description = $inputs['description'];
     $role->level = $inputs['level'];
     $role->save();
 }
 /**
  * 添加菜单--入库
  * 
  * @param        
  * 
  * @author        wen.zhou@bioon.com
  * 
  * @date        2015-10-18 12:19:40
  * 
  * @return        
  */
 public function postAdd()
 {
     $returnData = ['status' => false, 'msg' => '数据丢失'];
     /*添加角色*/
     $role = new Role();
     $role->name = request('name', '');
     $role->description = request('description', '');
     $role->slug = request('slug', '');
     $role->level = request('level', 1);
     $add_bool = $role->save();
     if ($add_bool) {
         /*添加权限*/
         $permissions = request('permissions', '');
         if (!empty($permissions)) {
             $role->detachAllPermissions();
             $selected_permissions = Permission::whereIn('slug', $permissions)->get();
             foreach ($selected_permissions as $selected_permission) {
                 $role->attachPermission($selected_permission);
             }
         }
         $returnData = ['status' => true, 'msg' => '修改成功'];
     } else {
         $returnData = ['status' => true, 'msg' => '修改成功'];
     }
     return response()->json($returnData);
 }