Пример #1
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create(Request $request)
 {
     $role = new Role();
     $role->name = trim($request->get('name'));
     $role->display_name = trim($request->get('display_name'));
     $role->description = trim($request->get('description'));
     $role->save();
     $role->perms()->sync($request->get('permission_id'));
     return redirect()->to('/admin/role/')->withErrors("操作成功");
 }
Пример #2
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;
 }