當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Role::save方法代碼示例

本文整理匯總了PHP中app\Role::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP Role::save方法的具體用法?PHP Role::save怎麽用?PHP Role::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Role的用法示例。


在下文中一共展示了Role::save方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $role = new Role();
     $role->name = Input::get('name');
     $role->save();
     return Redirect::route('template.role.index');
 }
開發者ID:jumaya,項目名稱:redbpim,代碼行數:12,代碼來源:RolesController.php

示例2: createdummies

 /**
  * Create a new controller instance.
  *
  * @return void
  */
 public function createdummies()
 {
     $wizard = new Role();
     $wizard->name = 'Wizard';
     $wizard->save();
     $muggle = new Role();
     $muggle->name = 'Muggle';
     $muggle->save();
     $castspells = new Permission();
     $castspells->name = 'can_castspells';
     $castspells->display_name = 'Can Cast Spells';
     $castspells->description = 'Enables you to cast awesome spells';
     $castspells->save();
     $bestupid = new Permission();
     $bestupid->name = 'can_bestupid';
     $bestupid->display_name = 'Be stupid';
     $bestupid->description = 'Enables you to be stupid and not see the magic around you';
     $bestupid->save();
     $wizard->attachPermission($castspells);
     $muggle->attachPermission($bestupid);
     $wiz_role = DB::Table('roles')->where('name', '=', 'Wizard')->pluck('id');
     $mug_role = DB::Table('roles')->where('name', '=', 'Muggle')->pluck('id');
     $harryPotter = User::where('username', '=', 'HarryPotter')->first();
     $harryPotter->roles()->attach($wiz_role);
     $smithwee = User::where('username', '=', 'SmithWee')->first();
     $smithwee->roles()->attach($mug_role);
     return 'Abracadabra!';
 }
開發者ID:muschottkey,項目名稱:bausbaus,代碼行數:33,代碼來源:ACLController.php

示例3: 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 = 'admin@admin.com';
     $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

示例4: 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

示例5: run

 /**
  * Run the database seeds.
  */
 public function run()
 {
     //初始化係統默認 Role
     foreach (['銷售', '售後', '產品', '硬件'] as $name) {
         $role = Role::where('name', $name)->first();
         if (!$role) {
             $role = new Role();
         }
         $role->name = $name;
         $role->system = true;
         $role->save();
     }
     //銷售權限設定
     $role = Role::where('name', '銷售')->first();
     $role->perms = ['產品查看', '服務器查看', '硬件查看', '客戶查看', '硬件查看', '項目查看', '客戶信息管理', '項目簽約', '項目信息管理', '項目模塊管理', '項目參數管理', '項目硬件管理', '項目服務器管理'];
     $role->save();
     //售後權限設定
     $role = Role::where('name', '售後')->first();
     $role->perms = ['產品查看', '服務器查看', '硬件查看', '客戶查看', '硬件查看', '項目查看', '項目信息管理', '項目模塊管理', '項目參數管理', '項目硬件管理', '項目服務器管理', '服務器信息管理', '項目文件管理', '項目外出記錄管理', '項目硬件部署管理'];
     $role->save();
     //產品權限設定
     $role = Role::where('name', '產品')->first();
     $role->perms = ['產品查看', '服務器查看', '硬件查看', '客戶查看', '硬件查看', '項目查看', '產品信息管理', '產品類別管理', '產品模塊管理', '產品參數管理', '服務器信息管理'];
     $role->save();
     //硬件權限設定
     $role = Role::where('name', '硬件')->first();
     $role->perms = ['產品查看', '服務器查看', '硬件查看', '客戶查看', '硬件查看', '項目查看', '硬件管理'];
     $role->save();
 }
開發者ID:genee-projects,項目名稱:snail,代碼行數:32,代碼來源:InitRoles.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: 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', '=', 'sander@dekroon.xyz')->first();
     $adminUser->attachRole($admin);
     $moderatorUser = User::where('email', '=', 'john@doe.nl')->first();
     $moderatorUser->attachRole($moderator);
     $normalUser = User::where('email', '=', 'marie@doe.nl')->first();
     $normalUser->attachRole($user);
     $guestUser = User::where('email', '=', 'gast@gastman.com')->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

示例8: 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

示例9: 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

示例10: 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', '=', 'admin@admin.com')->first();
     $assignedrole = new AssignedRoles();
     $assignedrole->user_id = $user->id;
     $assignedrole->role_id = $adminRole->id;
     $assignedrole->save();
     $user = User::where('email', '=', 'user@user.com')->first();
     $assignedrole = new AssignedRoles();
     $assignedrole->user_id = $user->id;
     $assignedrole->role_id = $commentRole->id;
     $assignedrole->save();
 }
開發者ID:Rotron,項目名稱:laravel5-shop,代碼行數:26,代碼來源:RolesTableSeeder.php

示例11: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('users')->insert(array(['id' => 1, 'name' => 'Admin', 'email' => 'admin@website.com', 'password' => Hash::make('admin'), 'created_at' => new DateTime(), 'updated_at' => new DateTime()], ['id' => 2, 'name' => 'Member', 'email' => 'member@website.com', '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

示例12: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $role = new Role();
     $role->name = 'admin';
     $role->display_name = '管理員';
     $role->save();
 }
開發者ID:alhs1995,項目名稱:DBFP,代碼行數:12,代碼來源:2015_12_19_041600_add_admin_role.php

示例13: postCreate

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate(Request $request)
 {
     // Declare the rules for the form validation
     $rules = array('name' => 'required|unique:roles', 'display_name' => 'required|unique:roles');
     // Validate the inputs
     $validator = Validator::make($request->all(), $rules, ['name.required' => 'A name is required.', 'name.unique' => 'Please use a different name.', 'display_name.required' => 'A display name is required', 'display_name.unique' => 'Please use a different display name.']);
     // Check if the form validates with success
     if ($validator->passes()) {
         // Get the inputs, with some exceptions
         $inputs = $request->except('csrf_token');
         $this->role->name = $request->input('name');
         $this->role->display_name = $request->input('display_name');
         $this->role->is_protected = $request->has('is_protected') ? 1 : 0;
         $this->role->is_superuser = $request->has('is_superuser') ? 1 : 0;
         $this->role->save();
         // Save permissions
         $this->role->perms()->sync($this->permission->preparePermissionsForSave($inputs['permissions']));
         // Was the role created?
         if ($this->role->id) {
             // Redirect to the new role page
             Flash::success('Created role');
             return redirect('admin/roles/' . $this->role->id . '/edit');
         }
         // Redirect to the new role page
         Flash::error('Could not create role');
         return redirect('admin/roles/create');
     }
     // Form validation failed
     return redirect('admin/roles/create')->withInput()->withErrors($validator);
 }
開發者ID:fetch404,項目名稱:fetch404,代碼行數:35,代碼來源:AdminRolesController.php

示例14: postCreate

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate(RoleRequest $request)
 {
     $is_admin = 0;
     // Check if role is for admin user
     if (!empty($request->permission)) {
         $permissionsAdmin = Permission::where('is_admin', '=', 1)->get();
         foreach ($permissionsAdmin as $perm) {
             foreach ($request->permission as $item) {
                 if ($item == $perm['id'] && $perm['is_admin'] == '1') {
                     $is_admin = 1;
                 }
             }
         }
     }
     $role = new Role();
     $role->is_admin = $is_admin;
     $role->name = $request->name;
     $role->save();
     if (is_array($request->permission)) {
         foreach ($request->permission as $item) {
             $permission = new PermissionRole();
             $permission->permission_id = $item;
             $permission->role_id = $role->id;
             $permission->save();
         }
     }
 }
開發者ID:ryleto,項目名稱:nightjar,代碼行數:32,代碼來源:RoleController.php

示例15: 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


注:本文中的app\Role::save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。