• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP app\Role类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中app\Role的典型用法代码示例。如果您正苦于以下问题:PHP Role类的具体用法?PHP Role怎么用?PHP Role使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Role类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: run

 public function run()
 {
     DB::table('roles')->delete();
     $adminRole = new Role();
     $adminRole->name = 'admin';
     $adminRole->display_name = 'admin';
     $adminRole->description = 'description';
     $adminRole->is_admin = 1;
     $adminRole->save();
     $commentRole = new Role();
     $commentRole->name = 'comment';
     $commentRole->display_name = 'comment';
     $commentRole->description = 'description';
     $commentRole->is_admin = 0;
     $commentRole->save();
     $user = User::where('email', '=', '[email protected]')->first();
     $assignedrole = new AssignedRoles();
     $assignedrole->user_id = $user->id;
     $assignedrole->role_id = $adminRole->id;
     $assignedrole->save();
     $user = User::where('email', '=', '[email protected]')->first();
     $assignedrole = new AssignedRoles();
     $assignedrole->user_id = $user->id;
     $assignedrole->role_id = $commentRole->id;
     $assignedrole->save();
 }
开发者ID:Rotron,项目名称:laravel5-shop,代码行数:26,代码来源:RolesTableSeeder.php


示例2: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Creating Roles
     $admin = new Role();
     $admin->name = 'admin';
     $admin->display_name = 'User Administrator';
     // optional
     $admin->description = 'User is allowed to manage and edit';
     // optional
     $admin->save();
     $moderator = new Role();
     $moderator->name = 'moderator';
     $moderator->display_name = 'Moderator';
     // optional
     $moderator->description = 'Moderator is allowed to moderate';
     // optional
     $moderator->save();
     $user = new Role();
     $user->name = 'user';
     $user->display_name = 'General User';
     // optional
     $user->description = 'General User is allowed to use facilities of the site';
     // optional
     $user->save();
     // creating an array of roles
     $roles = array($admin, $moderator, $user);
     // assigning roles to user
     $users = User::all();
     foreach ($users as $u) {
         $u->attachRole($roles[rand(0, 2)]);
     }
 }
开发者ID:enolareverof,项目名称:gameblog,代码行数:37,代码来源:EntrustTableSeeder.php


示例3: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $projectManager = new Role();
     $projectManager->name = 'project-manager';
     $projectManager->display_name = 'Project Manager';
     // optional
     $projectManager->description = 'User is the manager of a given project';
     // optional
     $projectManager->save();
     $admin = new Role();
     $admin->name = 'admin';
     $admin->display_name = 'User Administrator';
     // optional
     $admin->description = 'User is allowed to manage and edit other users';
     // optional
     $admin->save();
     $teamLeader = new Role();
     $teamLeader->name = 'team-leader';
     $teamLeader->display_name = 'Team Leader';
     // optional
     $teamLeader->description = 'User is the team leader of a given project';
     // optional
     $teamLeader->save();
     $programmer = new Role();
     $programmer->name = 'programmer';
     $programmer->display_name = 'Programmer';
     // optional
     $programmer->description = 'User is the team programmer of a given project';
     // optional
     $programmer->save();
 }
开发者ID:krisanalfa,项目名称:hisurugi,代码行数:36,代码来源:RoleTableSeeder.php


示例4: delete

 /**
  * Delete role
  * 
  * @param Role $role
  * @return \Illiminate\Http\RedirectResponse
  */
 public function delete(Role $role)
 {
     if ($role->id !== 1) {
         $role->delete();
     }
     return redirect('admin/roles/list');
 }
开发者ID:dookda,项目名称:mapigniter2,代码行数:13,代码来源:RoleController.php


示例5: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     /**
      * Create four roles: admin, moderator, user and guest.
      */
     $admin = new Role();
     $admin->name = 'admin';
     $admin->display_name = 'Administrator';
     $admin->description = 'Super User Do';
     $admin->save();
     $moderator = new Role();
     $moderator->name = 'moderator';
     $moderator->display_name = 'Moderator';
     $moderator->description = 'Kan alle bestellingen zien en gebruikergegevens opvragen.';
     $moderator->save();
     $user = new Role();
     $user->name = 'user';
     $user->display_name = 'Gebruiker';
     $user->description = 'Standaard gebruiker. Kan bestellingen plaatsen en eigen gegevens inkijken.';
     $user->save();
     $guest = new Role();
     $guest->name = 'guest';
     $guest->display_name = 'Gast';
     $guest->description = 'Standaard gebruiker. Kan bestellingen plaatsen.';
     $guest->save();
     /**
      * Attach roles to users.
      */
     $adminUser = User::where('email', '=', '[email protected]')->first();
     $adminUser->attachRole($admin);
     $moderatorUser = User::where('email', '=', '[email protected]')->first();
     $moderatorUser->attachRole($moderator);
     $normalUser = User::where('email', '=', '[email protected]')->first();
     $normalUser->attachRole($user);
     $guestUser = User::where('email', '=', '[email protected]')->first();
     $guestUser->attachRole($guest);
     /**
      * Create permissions.
      */
     $createPage = new Permission();
     $createPage->name = 'create-page';
     $createPage->display_name = 'Create Pages';
     $createPage->description = 'create new pages';
     $createPage->save();
     $editPage = new Permission();
     $editPage->name = 'edit-page';
     $editPage->display_name = 'Edit Pages';
     $editPage->description = 'edit existing pages';
     $editPage->save();
     $editUser = new Permission();
     $editUser->name = 'edit-user';
     $editUser->display_name = 'Edit Users';
     $editUser->description = 'edit existing users';
     $editUser->save();
     /**
      * Attach permissions to roles.
      */
     $admin->attachPermissions(array($createPage, $editPage, $editUser));
     $moderator->attachPermissions(array($createPage, $editPage));
 }
开发者ID:sanderdekroon,项目名称:yourfoodbox,代码行数:65,代码来源:RolesAndPermissions.php


示例6: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $admin = new Role();
     $admin->name = 'admin';
     $admin->display_name = 'Администратор';
     // optional
     $admin->description = '';
     // optional
     $admin->save();
     DB::table('users')->delete();
     $row1 = array_combine(['id', 'name', 'email', 'phone', 'avatar', 'provider', 'provider_id'], $this->items[0]) + ['password' => bcrypt('111111')];
     $user1 = User::create($row1);
     $row2 = array_combine(['id', 'name', 'email', 'phone', 'avatar', 'provider', 'provider_id'], $this->items[1]) + ['password' => bcrypt('111111')];
     $user2 = User::create($row2);
     $row3 = array_combine(['id', 'name', 'email', 'phone', 'avatar', 'provider', 'provider_id'], $this->items[2]) + ['password' => bcrypt('zaurzaur')];
     $user3 = User::create($row3);
     $row4 = array_combine(['id', 'name', 'email', 'phone', 'avatar', 'provider', 'provider_id'], $this->items[3]) + ['password' => bcrypt('16180339887')];
     $user4 = User::create($row4);
     $row5 = array_combine(['id', 'name', 'email', 'phone', 'avatar', 'provider', 'provider_id'], $this->items[4]) + ['password' => bcrypt('16180339887')];
     $user5 = User::create($row5);
     $user1->attachRole($admin);
     $user3->attachRole($admin);
     $user4->attachRole($admin);
     $user5->attachRole($admin);
 }
开发者ID:jambik,项目名称:sellmecar,代码行数:30,代码来源:UsersTableSeeder.php


示例7: setupFounderAndBaseRolesPermission

 /**
  *  Initialize the user group
  *
  */
 public function setupFounderAndBaseRolesPermission()
 {
     //Create Roles
     $founder = new Role();
     $founder->name = 'Founder';
     $founder->save();
     $admin = new Role();
     $admin->name = 'Admin';
     $admin->save();
     //Create User
     $user = new User();
     $user->name = 'muzhuang';
     $user->email = '[email protected]';
     $user->password = Hash::make('secret');
     if (!$user->save()) {
         Log::info('Unabel to create user ' . $user->username, (array) $user->errors());
     } else {
         Log::info('Create user "' . $user->username . '" <' . $user->email . '>');
     }
     //Attach Roles to user
     $user->roles()->attach($founder->id);
     //Create Permissions
     $manageUsers = new Permission();
     $manageUsers->name = 'admin.user';
     $manageUsers->display_name = 'Manage Users';
     $manageUsers->save();
     // Assign Permission to Role
     $founder->perms()->sync([$manageUsers->id]);
     $admin->perms()->sync([$manageUsers->id]);
 }
开发者ID:nutsdo,项目名称:mz-service,代码行数:34,代码来源:2015_03_07_085330_entrust_setup_tables.php


示例8: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(RoleFormRequest $request)
 {
     //Guarda datos del formulario de roles
     $role = new Role(array('name' => $request->get('name'), 'display_name' => $request->get('display_name'), 'description' => $request->get('description')));
     $role->save();
     return redirect('/admin/roles/create')->with('status', 'A new role has been created!');
 }
开发者ID:aabraham88,项目名称:blog,代码行数:13,代码来源:RolesController.php


示例9: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //Roles
     $userAdmin = new Role();
     $userAdmin->name = 'admin';
     $userAdmin->display_name = 'Administrator';
     $userAdmin->description = 'User is an admin and can edit and manage users';
     $userAdmin->save();
     $reportsUser = new Role();
     $reportsUser->name = 'reports-user';
     $reportsUser->display_name = 'Reports User';
     $reportsUser->description = 'Reports User can use Note Code Conflicts';
     $reportsUser->save();
     $csUser = new Role();
     $csUser->name = 'cs-user';
     $csUser->display_name = 'Customer Service User';
     $csUser->description = 'Customer Service User can Upload Notes Import';
     $csUser->save();
     //Permissions
     $userRegistration = new Permission();
     $userRegistration->name = 'user-reg';
     $userRegistration->display_name = 'User Registration';
     $userRegistration->description = 'Create new users admin only';
     $userRegistration->save();
     $manageUsers = new Permission();
     $manageUsers->name = 'manage-users';
     $manageUsers->display_name = 'Manage Users';
     $manageUsers->description = 'Manage Users - Permissions, etc.';
     $manageUsers->save();
     $reports = new Permission();
     $reports->name = 'reports';
     $reports->display_name = 'Reports Section';
     $reports->description = 'Access to reports section';
     $reports->save();
     $admin = new Permission();
     $admin->name = 'admin';
     $admin->display_name = 'Admin Section';
     $admin->description = 'Access to admin section';
     $admin->save();
     $dispositions = new Permission();
     $dispositions->name = 'dispositions';
     $dispositions->display_name = 'Disposition Uploads';
     $dispositions->description = 'Access to Disposition Uploads';
     $dispositions->save();
     $notesImport = new Permission();
     $notesImport->name = 'notes-import';
     $notesImport->display_name = 'Upload Notes Import';
     $notesImport->description = 'Access to upload notes import';
     $notesImport->save();
     $noteConflicts = new Permission();
     $noteConflicts->name = 'note-conflicts';
     $noteConflicts->display_name = 'Note Code Conflicts';
     $noteConflicts->description = 'Access to Node Code Conflicts';
     $noteConflicts->save();
     $batchRefund = new Permission();
     $batchRefund->name = 'batch-refund';
     $batchRefund->display_name = 'Batch Refunds';
     $batchRefund->description = 'Access to Batch Refunds';
     $batchRefund->save();
 }
开发者ID:shenlu2011,项目名称:internaltools,代码行数:65,代码来源:PermissionsSeeder.php


示例10: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('users')->insert(array(['id' => 1, 'name' => 'Admin', 'email' => '[email protected]', 'password' => Hash::make('admin'), 'created_at' => new DateTime(), 'updated_at' => new DateTime()], ['id' => 2, 'name' => 'Member', 'email' => '[email protected]', 'password' => Hash::make('member'), 'created_at' => new DateTime(), 'updated_at' => new DateTime()]));
     $admin = new Role();
     $admin->name = 'admin';
     $admin->display_name = 'User Administrator';
     $admin->description = 'User is allowed to manage and edit other users';
     $admin->save();
     $member = new Role();
     $member->name = 'member';
     $member->display_name = 'Member';
     $member->description = 'User is a member';
     $member->save();
     $user = User::where('name', '=', 'Admin')->first();
     $user->attachRole($admin);
     $user = User::where('name', '=', 'Member')->first();
     $user->attachRole($member);
     $addLocal = new Permission();
     $addLocal->name = 'add-local';
     $addLocal->display_name = 'Add Local Site';
     $addLocal->description = 'add new local site';
     $addLocal->save();
     $viewContent = new Permission();
     $viewContent->name = 'view-content';
     $viewContent->display_name = 'View Content';
     $viewContent->description = 'view content in system';
     $viewContent->save();
     $admin->attachPermission($addLocal);
     $admin->attachPermission($viewContent);
     $member->attachPermission($viewContent);
 }
开发者ID:BooMamoo,项目名称:server,代码行数:36,代码来源:UserTableSeeder.php


示例11: updatePermissions

 /**
  * Assign permissions to role
  */
 public function updatePermissions(Request $request, Role $role)
 {
     $permissions = $request->checkedPermissions ?: [];
     // $permissions = array of submitted permissions OR if all checkboxes were unchecked, make it an empty array
     $role->permissions()->sync($permissions);
     logThis('Permissions for ' . $role->label . ' changed to ' . $role->permissions()->lists('label'));
     return $role->load('permissions');
 }
开发者ID:goatatwork,项目名称:access2,代码行数:11,代码来源:RolesApiController.php


示例12: run

 public function run()
 {
     $this->command->info('Roles data seeded!');
     $owner = new Role();
     $owner->name = 'owner';
     $owner->display_name = 'Owner';
     // optional
     $owner->description = 'Root';
     // optional
     $owner->save();
     $admin = new Role();
     $admin->name = 'admin';
     $admin->display_name = 'Administrator';
     // optional
     $admin->description = 'Administradores';
     // optional
     $admin->save();
     $this->command->info('Roles data attaching to users!');
     if ($owner) {
         $owner_user = User::where('name', '=', 'owner')->first();
         // role attach alias
         $owner_user->attachRole($owner);
         // parameter can be an Role object, array, or id
         $this->command->info('Owner role attached!');
     }
     if ($admin) {
         $admin_user = User::where('name', '=', 'ligacbb')->first();
         // role attach alias
         $admin_user->attachRole($admin);
         // parameter can be an Role object, array, or id
         $this->command->info('Admin role attached!');
     }
     $this->command->info('Creating Permissions!');
     $owner_permission = new Permission();
     $owner_permission->name = 'owner-permission';
     $owner_permission->display_name = 'Full control';
     // optional
     // Allow a user to...
     $owner_permission->description = '';
     // optional
     $owner_permission->save();
     $admin_permission = new Permission();
     $admin_permission->name = 'admin-permission';
     $admin_permission->display_name = 'Admin permission';
     // optional
     // Allow a user to...
     $admin_permission->description = '';
     // optional
     $admin_permission->save();
     $this->command->info('Attaching Owner Permission!');
     $owner->attachPermission($owner_permission);
     // equivalent to $admin->perms()->sync(array($owner_permission->id));
     $this->command->info('Attaching Admin Permission!');
     $admin->attachPermission($admin_permission);
     // equivalent to $owner->perms()->sync(array($createPost->id, $editUser->id));
 }
开发者ID:emitategh,项目名称:aabcehmt,代码行数:56,代码来源:RolesPermissionsSeeder.php


示例13: dashboard

 public function dashboard(Request $request, User $user, Role $roles, Message $messages)
 {
     $user = Auth::user();
     $user->usersCount = $user->all()->count();
     $user->rolesCount = $roles->all()->count();
     $user->contactsCount = $user->contacts()->count();
     $user->todosCount = $user->todos()->whereDone(0)->count();
     $user->messagesCount = $messages->whereViewed(0)->count();
     return view('dashboard.index', compact('user'));
 }
开发者ID:Yismen,项目名称:solpieles,代码行数:10,代码来源:HomeController.php


示例14: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     foreach ($this->roles as $role) {
         $roleModel = new Role();
         $roleModel->name = $role['name'];
         $roleModel->level = $role['level'];
         $roleModel->save();
     }
     $this->info('User roles generated with success');
 }
开发者ID:bitller,项目名称:nova,代码行数:15,代码来源:GenerateRoles.php


示例15: checkByAjax

 public function checkByAjax()
 {
     $nameRole = Input::get('newRoleName');
     $model = new Role();
     if ($model->where('name', $nameRole)->count() > 0) {
         return 0;
     } else {
         return 1;
     }
 }
开发者ID:hungnt167,项目名称:CDShop,代码行数:10,代码来源:RoleController.php


示例16: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $input = Request::except('_token');
     //dd($input);
     $rol = new Role();
     $rol->name = $input['roles'];
     $rol->description = $input['description'];
     $rol->save();
     return URL::To('roles');
 }
开发者ID:rikardote,项目名称:portal,代码行数:16,代码来源:RolesController.php


示例17: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $role_super_admin = new Role();
     $role_super_admin->name = 'Super Admin';
     $role_super_admin->description = 'The super admin account for the application';
     $role_super_admin->save();
     $role_user = new Role();
     $role_user->name = 'Candidate';
     $role_user->description = 'Normal candidate account for the application with minimum permissions';
     $role_user->save();
 }
开发者ID:shineklbm,项目名称:laravel-backend,代码行数:16,代码来源:RoleTableSeeder.php


示例18: destroy

 public function destroy(Role $role)
 {
     if (!Helper::getMode()) {
         return redirect()->back()->withErrors(config('constants.DISABLE_MESSAGE'));
     }
     if ($role->name == 'admin') {
         return redirect('/configuration#permission')->withErrors(config('constants.INVALID_LINK'));
     }
     $role->delete();
     return redirect()->back()->withSuccess(config('constants.DELETED'));
 }
开发者ID:EneaWeb,项目名称:aliangel,代码行数:11,代码来源:RoleController.php


示例19: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['name' => 'required|unique:roles']);
     $role = new Role();
     $role->name = $request->name;
     $role->display_name = $request->display_name;
     $role->description = $request->description;
     $role->save();
     Session::flash('flash_message', 'Role successfully added.');
     Session::flash('flash_class', 'alert-success');
     return redirect()->route("roles.index");
 }
开发者ID:renciebautista,项目名称:pcount2,代码行数:18,代码来源:RoleController.php


示例20: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $role = new Role();
     $role->description = "user";
     $role->save();
     $role = new Role();
     $role->description = "tech";
     $role->save();
     $role->users()->attach(User::defaultUser());
     $role = new Role();
     $role->description = "admin";
     $role->save();
 }
开发者ID:noikiy,项目名称:Laravel-5-Helpdesk,代码行数:18,代码来源:RoleTableSeeder.php



注:本文中的app\Role类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP app\Setting类代码示例发布时间:2022-05-23
下一篇:
PHP app\Question类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap