Пример #1
0
 public function edit_permission_assign(Request $request)
 {
     //        return dd($request->all());
     if (Auth::check()) {
         if (User::isSuperAdmin()) {
             if (!is_null($request->input('role_group')) and $request->input('role_group') != "") {
                 Role_Permission::where('role_id', $request->input('role_group'))->delete();
                 $prm_obj = Permission::all();
                 foreach ($prm_obj as $index) {
                     if ($request->input($index->name) == "on") {
                         $perm_role = new Role_Permission();
                         $perm_role->permission_id = $index->id;
                         $perm_role->role_id = $request->input('role_group');
                         $perm_role->save();
                     }
                 }
                 return \Redirect::back()->withErrors(['success' => true, 'msg' => "Permission Role Assigned Successfully"]);
             }
             return \Redirect::back()->withErrors(['success' => false, 'msg' => 'Select One Role plz']);
         }
         return \Redirect::back()->withErrors(['success' => false, 'msg' => 'You don\'t have permission']);
     }
     return Redirect::to(url('user/login'));
 }