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


PHP Role::create方法代碼示例

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


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

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $validation = Validator::make($input, Role::$rules);
     if ($validation->passes()) {
         $this->role->create($input);
         return Redirect::route('roles.index');
     }
     return Redirect::route('roles.create')->withInput()->withErrors($validation)->with('message', trans('validation.errors'));
 }
開發者ID:alex-petkevich,項目名稱:proweb5,代碼行數:15,代碼來源:RolesController.php

示例2: run

 public function run()
 {
     $roles = array('Admin', 'Manager', 'Programmer');
     foreach ($roles as $role) {
         Role::create(array('name' => $role));
     }
 }
開發者ID:vik0803,項目名稱:BugTrackerApp,代碼行數:7,代碼來源:RolesTableSeeder.php

示例3: up

 public function up()
 {
     Schema::create('users', function ($table) {
         $table->increments('id');
         $table->string('email');
         $table->string('password');
         $table->string('name');
         $table->timestamps();
     });
     User::create(array('id' => 1, 'email' => 'admin@domain.com', 'password' => Hash::make('admin'), 'name' => 'Mr. Administrator'));
     User::create(array('id' => 2, 'email' => 'moderator@domain.com', 'password' => Hash::make('moderator'), 'name' => 'Mr. Moderator'));
     Schema::create('roles', function ($table) {
         $table->increments('id');
         $table->string('name');
         $table->timestamps();
     });
     Role::create(array('id' => 1, 'name' => 'administrator'));
     Role::create(array('id' => 2, 'name' => 'moderator'));
     Schema::create('role_user', function ($table) {
         $table->increments('id');
         $table->integer('user_id');
         $table->integer('role_id');
         $table->timestamps();
     });
     User::find(1)->roles()->attach(1);
     User::find(2)->roles()->attach(2);
 }
開發者ID:SerdarSanri,項目名稱:authority-laravel,代碼行數:27,代碼來源:2012_01_24_205457_add_authority_tables.php

示例4: run

 public function run()
 {
     DB::table('Roles')->delete();
     Role::create(array('name' => 'admin'));
     Role::create(array('name' => 'teller'));
     Role::create(array('name' => 'customer'));
 }
開發者ID:yeyande,項目名稱:CS499,代碼行數:7,代碼來源:DatabaseSeeder.php

示例5: generate

 private function generate()
 {
     $roles = array('admin', 'member');
     foreach ($roles as $role) {
         Role::create(array('name' => $role));
     }
 }
開發者ID:kcsamita,項目名稱:laravelsnippets,代碼行數:7,代碼來源:RoleSeeder.php

示例6: addRole

 public function addRole()
 {
     $rol = Role::all();
     $isAdded = FALSE;
     $validInput = TRUE;
     $regex = "/^[a-zA-Z\\'\\-]+( [a-zA-Z\\'\\-]+)*\$/";
     $regexDesc = "/^[a-zA-Z0-9\\'\\-\\.\\,]+( [a-zA-Z0-9\\,\\'\\-\\.]+)*\$/";
     if (!trim(Input::get('addRoleName')) == '' && !trim(Input::get('addRoleDescription')) == '') {
         $validInput = TRUE;
         if (preg_match($regex, Input::get('addRoleName')) && preg_match($regexDesc, Input::get('addRoleDescription'))) {
             $validInput = TRUE;
         } else {
             $validInput = FALSE;
         }
     } else {
         $validInput = FALSE;
     }
     foreach ($rol as $rol) {
         if (strcasecmp($rol->strEmpRoleName, trim(Input::get('addRoleName'))) == 0) {
             $isAdded = TRUE;
         }
     }
     if ($validInput) {
         if (!$isAdded) {
             $role = Role::create(array('strEmpRoleID' => Input::get('addRoleID'), 'strEmpRoleName' => trim(Input::get('addRoleName')), 'strEmpRoleDesc' => trim(Input::get('addRoleDescription')), 'boolIsActive' => 1));
             $role->save();
             return Redirect::to('/maintenance/employeeRole?success=true');
         } else {
             return Redirect::to('/maintenance/employeeRole?success=duplicate');
         }
     } else {
         return Redirect::to('/maintenance/employeeRole?input=invalid');
     }
 }
開發者ID:MorrielAlexis,項目名稱:SADTAILORING,代碼行數:34,代碼來源:RoleController.php

示例7: run

 public function run()
 {
     /**
      * Truncate Tables
      */
     Permission::truncate();
     Role::truncate();
     User::truncate();
     DB::table('assigned_roles')->truncate();
     DB::table('permission_role')->truncate();
     /**
      * Seed Datas
      */
     $permissions = [['name' => 'Role:list', 'display_name' => 'List Roles', 'group_name' => 'Role'], ['name' => 'Role:show', 'display_name' => 'Show Role', 'group_name' => 'Role'], ['name' => 'Role:create', 'display_name' => 'Create New Role', 'group_name' => 'Role'], ['name' => 'Role:edit', 'display_name' => 'Edit Existing Role', 'group_name' => 'Role'], ['name' => 'Role:delete', 'display_name' => 'Delete Existing Role', 'group_name' => 'Role'], ['name' => 'Permission:list', 'display_name' => 'List Permissions', 'group_name' => 'Permission'], ['name' => 'Permission:show', 'display_name' => 'Show Permission', 'group_name' => 'Permission'], ['name' => 'Permission:create', 'display_name' => 'Create New Permission', 'group_name' => 'Permission'], ['name' => 'Permission:edit', 'display_name' => 'Edit Existing Permission', 'group_name' => 'Permission'], ['name' => 'Permission:delete', 'display_name' => 'Delete Existing Permission', 'group_name' => 'Permission'], ['name' => 'User:list', 'display_name' => 'List Users', 'group_name' => 'Users'], ['name' => 'User:show', 'display_name' => 'Show User', 'group_name' => 'Users'], ['name' => 'User:create', 'display_name' => 'Create New User', 'group_name' => 'Users'], ['name' => 'User:edit', 'display_name' => 'Edit Existing User', 'group_name' => 'Users'], ['name' => 'User:delete', 'display_name' => 'Delete Existing User', 'group_name' => 'Users'], ['name' => 'User:set_confirmation', 'display_name' => 'Set Existing User\'s Confirmed Status', 'group_name' => 'Users'], ['name' => 'User:set_password', 'display_name' => 'Set Existing User\'s Password', 'group_name' => 'Users']];
     $roles = [['name' => 'Admin'], ['name' => 'Role Admin'], ['name' => 'Permission Admin'], ['name' => 'User Admin'], ['name' => 'User'], ['name' => 'Upload Admin']];
     $users = [['first_name' => 'System', 'last_name' => 'Administrator', 'username' => 'admin', 'email' => 'admin@example.com', 'password' => 'admin', 'password_confirmation' => 'admin', 'confirmed' => 1], ['first_name' => 'System', 'last_name' => 'User', 'username' => 'user', 'email' => 'user@example.com', 'password' => 'user', 'password_confirmation' => 'user', 'confirmed' => 1]];
     $user_roles = [1 => [1], 2 => [6]];
     /**
      * Insert Into DB
      */
     foreach ($permissions as $data) {
         Permission::create($data);
     }
     foreach ($roles as $data) {
         Role::create($data);
     }
     foreach ($users as $data) {
         $user = User::create($data);
         if (isset($user_roles[$user->id])) {
             $user->roles()->sync($user_roles[$user->id]);
         }
     }
 }
開發者ID:k4ml,項目名稱:laravel-base,代碼行數:33,代碼來源:LaravelBaseSeeder.php

示例8: run

 public function run()
 {
     Role::create(['name' => 'super_admin', 'friendly_name' => 'Super Admin']);
     Role::create(['name' => 'admin', 'friendly_name' => 'Admin']);
     Role::create(['name' => 'user', 'friendly_name' => 'User']);
     Role::create(['name' => 'guest', 'friendly_name' => 'Guest']);
 }
開發者ID:Zipcore,項目名稱:Sourcemod-Server-Manager-System,代碼行數:7,代碼來源:RolesTableSeeder.php

示例9: run

 public function run()
 {
     $roles = ['admin', 'manager', 'member'];
     foreach ($roles as $role) {
         Role::create(['name' => $role]);
     }
 }
開發者ID:udayrockstar,項目名稱:RestaurantManager,代碼行數:7,代碼來源:RolesTableSeeder.php

示例10: run

 public function run()
 {
     //removes existing roles from table
     DB::table('roles')->delete();
     Role::create(['name' => 'admin']);
     Role::create(['name' => 'member']);
 }
開發者ID:pogliozzy,項目名稱:larabase,代碼行數:7,代碼來源:RolesTableSeeder.php

示例11: run

 public function run()
 {
     Role::create(['name' => 'Super Administrator']);
     Role::create(['name' => 'Employee MS Administrator']);
     Role::create(['name' => 'Property MS Administrator']);
     Role::create(['name' => 'Performance MS Administrator']);
 }
開發者ID:codeblues1516,項目名稱:godaddy,代碼行數:7,代碼來源:RolesTableSeeder.php

示例12: run

 public function run()
 {
     //$faker = Faker::create();
     $roles = ['Admin'];
     foreach ($roles as $role) {
         Role::create(['name' => $role]);
     }
 }
開發者ID:scdnlab,項目名稱:cse_carnival_2015,代碼行數:8,代碼來源:RolesTableSeeder.php

示例13: run

 public function run()
 {
     //$faker = Faker::create();
     $roles = Config::get('customConfig.roles');
     foreach ($roles as $role) {
         Role::create(['name' => $role]);
     }
 }
開發者ID:masiur,項目名稱:random,代碼行數:8,代碼來源:RolesTableSeeder.php

示例14: run

 public function run()
 {
     DB::table('roles')->delete();
     Role::create(array('ime' => 'Administrator', 'opis' => 'Ima sve ovlasti u sustavu i određuje ovlasti drugima.'));
     Role::create(array('ime' => 'Instruktor', 'opis' => 'Održava instrukcije.'));
     Role::create(array('ime' => 'Voditelj tečaja', 'opis' => 'Održava instrukcije. Ima dodatnu mogućnost označiti ih kao tečaj.'));
     Role::create(array('ime' => 'Asistent', 'opis' => 'Uklanja greške pri unosu prouzročene od Instruktora.'));
 }
開發者ID:Firtzberg,項目名稱:Edu,代碼行數:8,代碼來源:RolesTableSeeder.php

示例15: run

 public function run()
 {
     Eloquent::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     // Roles
     DB::table('roles')->delete();
     Role::create(array('name' => 'Admin'));
     Role::create(array('name' => 'Manager'));
     Role::create(array('name' => 'Player'));
     // Users
     DB::table('users')->delete();
     // Admin
     $user = new User();
     $user->email = 'jp.bourdon@mid-amateur.be';
     $user->password = 'Birdie002$';
     $user->username = 'Jpb';
     $user->password_confirmation = 'Birdie002$';
     $user->confirmation_code = md5(uniqid(mt_rand(), true));
     $user->confirmed = 1;
     if (!$user->save()) {
         Log::info('Unable to create user ' . $user->email, (array) $user->errors());
     } else {
         Log::info('Created user ' . $user->email);
     }
     $userRole = DB::table('roles')->where('name', '=', 'Admin')->pluck('id');
     $user->roles()->attach($userRole);
     // Manager
     $user = new User();
     $user->email = 'jp.bourdon.midam@gmail.com';
     $user->password = '1111';
     $user->username = 'Jpb-Manager';
     $user->password_confirmation = '1111';
     $user->confirmation_code = md5(uniqid(mt_rand(), true));
     $user->confirmed = 1;
     if (!$user->save()) {
         Log::info('Unable to create user ' . $user->email, (array) $user->errors());
     } else {
         Log::info('Created user ' . $user->email);
     }
     $userRole = DB::table('roles')->where('name', '=', 'Manager')->pluck('id');
     $user->roles()->attach($userRole);
     // Player
     $user = new User();
     $user->email = 'infos@mid-amateur.be';
     $user->password = '1111';
     $user->username = 'Jpb-Player';
     $user->password_confirmation = '1111';
     $user->confirmation_code = md5(uniqid(mt_rand(), true));
     $user->confirmed = 1;
     if (!$user->save()) {
         Log::info('Unable to create user ' . $user->email, (array) $user->errors());
     } else {
         Log::info('Created user ' . $user->email);
     }
     $userRole = DB::table('roles')->where('name', '=', 'Player')->pluck('id');
     $user->roles()->attach($userRole);
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
 }
開發者ID:birdiebel,項目名稱:G2016,代碼行數:58,代碼來源:InitialTableSeeder.php


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