Beispiel #1
0
 public function createRole($name, $display_name)
 {
     $role = Role::where("name", '=', $name)->get()->first();
     if (!$role) {
         // 创建组
         $role = new Role();
         $role->name = $name;
         $role->display_name = $display_name;
         $role->save();
     }
     return $role;
 }
Beispiel #2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $role = Role::where('id', '=', $id)->first();
     if (empty($role)) {
         return redirect()->to('/admin/role/')->withErrors("删除失败");
     }
     $role->delete();
     return redirect()->to('/admin/role/')->withErrors("删除成功");
 }
Beispiel #3
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $show['user'] = User::where('id', '=', $id)->first();
     // 获取全部角色
     $show['role'] = Role::all();
     // 获取全部权限, 用来判断那些全选选中了
     $role_user = DB::table('role_user')->where('user_id', '=', $id)->get();
     foreach ($role_user as $value) {
         $show['role_user'][$value->role_id] = 1;
     }
     return View('admin.user.edit', ['title' => '后台管理 - 修改账号', 'show' => $show]);
 }