コード例 #1
0
ファイル: UsersController.php プロジェクト: majumder5niru/HMS
 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
ファイル: RolesController.php プロジェクト: alkindi91/DARES
 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
ファイル: BlogRoleRepository.php プロジェクト: facilinfo/blog
 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();
 }
コード例 #4
0
 /**
  * 添加菜单--入库
  * 
  * @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);
 }