本文整理汇总了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'));
}
示例2: run
public function run()
{
$roles = array('Admin', 'Manager', 'Programmer');
foreach ($roles as $role) {
Role::create(array('name' => $role));
}
}
示例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);
}
示例4: run
public function run()
{
DB::table('Roles')->delete();
Role::create(array('name' => 'admin'));
Role::create(array('name' => 'teller'));
Role::create(array('name' => 'customer'));
}
示例5: generate
private function generate()
{
$roles = array('admin', 'member');
foreach ($roles as $role) {
Role::create(array('name' => $role));
}
}
示例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');
}
}
示例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]);
}
}
}
示例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']);
}
示例9: run
public function run()
{
$roles = ['admin', 'manager', 'member'];
foreach ($roles as $role) {
Role::create(['name' => $role]);
}
}
示例10: run
public function run()
{
//removes existing roles from table
DB::table('roles')->delete();
Role::create(['name' => 'admin']);
Role::create(['name' => 'member']);
}
示例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']);
}
示例12: run
public function run()
{
//$faker = Faker::create();
$roles = ['Admin'];
foreach ($roles as $role) {
Role::create(['name' => $role]);
}
}
示例13: run
public function run()
{
//$faker = Faker::create();
$roles = Config::get('customConfig.roles');
foreach ($roles as $role) {
Role::create(['name' => $role]);
}
}
示例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.'));
}
示例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;');
}