本文整理汇总了PHP中app\models\Role::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::create方法的具体用法?PHP Role::create怎么用?PHP Role::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Role
的用法示例。
在下文中一共展示了Role::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
DB::statement('SET FOREIGN_KEY_CHECKS = 0');
DB::table('permission_role')->truncate();
DB::table('role_user')->truncate();
DB::table('users')->truncate();
DB::table('roles')->truncate();
DB::table('permissions')->truncate();
DB::table('permission_groups')->truncate();
DB::statement('SET FOREIGN_KEY_CHECKS = 1');
$faker = Faker\Factory::create();
//User
$admin = User::create(['email' => 'admin@admin.com', 'name' => '管理员', 'password' => bcrypt('adminadmin')]);
$test_user = User::create(['email' => 'test@test.com', 'name' => '测试用户', 'password' => bcrypt('testtest')]);
//Roles
$role_admin = Role::create(['name' => 'admin', 'display_name' => '管理员']);
$role_editor = Role::create(['name' => 'editor', 'display_name' => '编辑']);
$role_user = Role::create(['name' => 'user', 'display_name' => '普通用户']);
//Permission&PermissionGroup
PermissionGroup::create(['name' => '后台']);
PermissionGroup::create(['name' => 'RBAC', 'parent_id' => 1]);
Permission::create(['name' => 'dashboard_view', 'display_name' => '首页', 'group_id' => 1]);
$models = [['route_name' => 'users', 'menu_name' => '帐户', 'group_id' => 3, 'group_pid' => 2], ['route_name' => 'roles', 'menu_name' => '角色', 'group_id' => 4, 'group_pid' => 2], ['route_name' => 'permissions', 'menu_name' => '权限', 'group_id' => 5, 'group_pid' => 2], ['route_name' => 'permissiongroups', 'menu_name' => '权限分组', 'group_id' => 6, 'group_pid' => 2], ['route_name' => 'articles', 'menu_name' => '文章', 'group_id' => 7, 'group_pid' => 1], ['route_name' => 'settings', 'menu_name' => '配置', 'group_id' => 8, 'group_pid' => 1]];
foreach ($models as $key => $model) {
PermissionGroup::create(['name' => $model['menu_name'], 'parent_id' => $model['group_pid']]);
Permission::create(['group_id' => $model['group_id'], 'name' => $model['route_name'] . '_view', 'display_name' => $model['menu_name'] . '菜单']);
Permission::create(['group_id' => $model['group_id'], 'name' => $model['route_name'] . '_create', 'display_name' => '新建' . $model['menu_name']]);
Permission::create(['group_id' => $model['group_id'], 'name' => $model['route_name'] . '_update', 'display_name' => '修改' . $model['menu_name']]);
Permission::create(['group_id' => $model['group_id'], 'name' => $model['route_name'] . '_delete', 'display_name' => '删除' . $model['menu_name']]);
}
//Roles Users
$test_user->roles()->save($role_editor);
//Roles Users
// $role_admin->givePermissionTo($permission_admin_user);
}
示例2: run
public function run()
{
Model::unguard();
Role::create(['name' => 'admin']);
Role::create(['name' => 'moderator']);
Role::create(['name' => 'user']);
}
示例3: store
/**
* Store a newly created Role in storage.
*
* @param CreateRoleRequest $request
*
* @return Response
*/
public function store(CreateRoleRequest $request)
{
$input = $request->all();
$role = Role::create($input);
Flash::message('Role saved successfully.');
return redirect(route('admin.roles.index'));
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(StoreRoleRequest $request)
{
//
Role::create($request->all());
$status = 'New Role added.';
return \Redirect::route($this->view_idx)->with(['status' => $status]);
}
示例5: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
Role::create(['title' => 'Administrator', 'slug' => 'admin']);
User::create(['username' => 'Gazpar Gloria', 'email' => 'gazpargloria@gcingenieria.com.mx', 'password' => bcrypt('GGGCI*16'), 'seen' => true, 'role_id' => 1, 'confirmed' => true]);
User::create(['username' => 'Leonardo Balderas', 'email' => 'leonardobalderas@gcingenieria.com.mx', 'password' => bcrypt('LBGCI*16'), 'seen' => true, 'role_id' => 1, 'valid' => true, 'confirmed' => true]);
}
示例6: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
*
* @return mixed
*/
public function store(Request $request)
{
$this->validate($request, ['role' => 'required|unique:roles']);
Role::create($request->all());
\Flash::success('Role added!');
return redirect('admin/data-management/roles');
}
示例7: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('roles')->delete();
Role::create(['name' => 'user']);
Role::create(['name' => 'editor']);
Role::create(['name' => 'administrator']);
}
示例8: run
public function run()
{
DB::statement("SET foreign_key_checks = 0");
Role::truncate();
Role::create(['name' => 'user']);
Role::create(['name' => 'administrator']);
}
示例9: run
public function run()
{
$faker = Faker::create('en_US');
/*
* Base User Accounts
*/
// Mike's account
$michael = User::create(['name' => 'Michael Norris', 'email' => 'mstnorris@gmail.com', 'password' => bcrypt('password'), 'must_reset_password' => false, 'verify_token' => null, 'verified_on' => Carbon::now(), 'active_on' => Carbon::now(), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
$michaelProfile = Profile::create(['user_id' => $michael->id, 'username' => 'mstnorris', 'salutation' => 'Mr', 'first_name' => 'Michael', 'middle_name' => 'Stephen Thomas', 'last_name' => 'Norris', 'nick_name' => 'Mike', 'date_of_birth' => '1988-08-17', 'address_line_1' => '78A Sackville Road', 'address_line_2' => '', 'address_line_3' => '', 'address_line_4' => '', 'address_city' => 'Hove', 'address_county' => 'East Sussex', 'address_postcode' => 'BN3 3HB', 'private_email_address' => 'mstnorris@gmail.com', 'mobile_number' => '+44 (0) 7446 990 061', 'twitter_username' => 'mstnorris', 'facebook_username' => 'mstnorris', 'google_plus_username' => 'mstnorris', 'instagram_username' => 'mstnorris', 'profile_photo_url' => '/images/mike.jpg', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
$michael->profile()->save($michaelProfile);
// Sezer's account
$sezer = User::create(['name' => 'Sezer Tunca', 'email' => 'sezertunca@gmail.com', 'password' => bcrypt('password'), 'must_reset_password' => false, 'verify_token' => null, 'verified_on' => Carbon::now(), 'active_on' => Carbon::now(), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
$sezerProfile = Profile::create(['user_id' => $sezer->id, 'username' => 'sezertunca', 'salutation' => 'Mr', 'first_name' => 'Sezer', 'middle_name' => '', 'last_name' => 'Tunca', 'nick_name' => 'Sezer', 'date_of_birth' => '1989-05-02', 'address_line_1' => 'Flat 4', 'address_line_2' => '15 Burlington Street', 'address_line_3' => '', 'address_line_4' => '', 'address_city' => 'Brighton', 'address_county' => 'East Sussex', 'address_postcode' => 'BN2 1AA', 'private_email_address' => 'sezertunca@gmail.com', 'mobile_number' => '+44 (0) 7545 278 156', 'twitter_username' => 'sezertunca', 'facebook_username' => 'sezertunca', 'google_plus_username' => 'sezertunca', 'instagram_username' => 'sezertunca', 'profile_photo_url' => '/images/sezer.jpg', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
$sezer->profile()->save($sezerProfile);
// Holly's account
$holly = User::create(['name' => 'Holly McNicol', 'email' => 'holly.mcnicol@live.co.uk', 'password' => bcrypt('password'), 'must_reset_password' => false, 'verify_token' => null, 'verified_on' => Carbon::now(), 'active_on' => Carbon::now(), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
$hollyProfile = Profile::create(['user_id' => $holly->id, 'username' => 'hjmcnicol', 'salutation' => 'Miss', 'first_name' => 'Holly', 'middle_name' => 'Jane', 'last_name' => 'McNicol', 'nick_name' => 'Holly', 'date_of_birth' => '1990-05-16', 'address_line_1' => '78A Sackville Road', 'address_line_2' => '', 'address_line_3' => '', 'address_line_4' => '', 'address_city' => 'Hove', 'address_county' => 'East Sussex', 'address_postcode' => 'BN3 3HB', 'private_email_address' => 'holly.mcnicol@live.co.uk', 'mobile_number' => '+44 (0) 7950 994 570', 'twitter_username' => 'hjmcnicol', 'facebook_username' => 'hjmcnicol', 'google_plus_username' => 'hjmcnicol', 'instagram_username' => 'hjmcnicol', 'profile_photo_url' => '/images/holly.jpg', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
$holly->profile()->save($hollyProfile);
// Jane's account
$jane = User::create(['name' => 'Jane Challenger-Gillitt', 'email' => 'j.m.challenger-gillitt@brighton.ac.uk', 'password' => bcrypt('password'), 'must_reset_password' => false, 'verify_token' => null, 'verified_on' => Carbon::now(), 'active_on' => Carbon::now(), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
$janeProfile = Profile::create(['user_id' => $jane->id, 'username' => 'jmchallengergillitt', 'salutation' => 'Mrs', 'first_name' => 'Jane', 'middle_name' => '', 'last_name' => 'Challenger-Gillitt', 'nick_name' => 'Jane', 'date_of_birth' => '1980-01-01', 'address_line_1' => '1 Hove Road', 'address_line_2' => '', 'address_line_3' => '', 'address_line_4' => '', 'address_city' => 'Hove', 'address_county' => 'East Sussex', 'address_postcode' => 'BN3 3BN', 'private_email_address' => 'jane.challenger-gillitt@gmail.com', 'mobile_number' => '+44 (0) 7987 654 321', 'twitter_username' => 'jmchallengergillitt', 'facebook_username' => 'jmchallengergillitt', 'google_plus_username' => 'jmchallengergillitt', 'instagram_username' => 'jmchallengergillitt', 'profile_photo_url' => 'https://placeholdit.imgix.net/~text?txt=JCG&txtsize=80&bg=eceff1&txtclr=607d8b&w=640&h=640', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
$jane->profile()->save($janeProfile);
// Super Administrator (User)
$superU = User::create(['name' => 'Super Administrator', 'email' => 'super@getwhiteboard.com', 'password' => bcrypt('password'), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
$superUProfile = Profile::create(['user_id' => $superU->id, 'username' => 'superadmin', 'salutation' => 'Mr', 'first_name' => 'Super', 'middle_name' => '', 'last_name' => 'Administrator', 'nick_name' => 'SuperAdmin', 'date_of_birth' => '1980-01-01', 'address_line_1' => 'Address line 1', 'address_line_2' => '', 'address_line_3' => '', 'address_line_4' => '', 'address_city' => 'Hove', 'address_county' => 'East Sussex', 'address_postcode' => 'BN3 3HB', 'private_email_address' => 'superadmin@contest.dev', 'mobile_number' => '+44 (0) 7950 994 570', 'twitter_username' => 'superadmin', 'facebook_username' => 'superadmin', 'google_plus_username' => 'superadmin', 'instagram_username' => 'superadmin', 'profile_photo_url' => 'https://placeholdit.imgix.net/~text?txt=SUP&txtsize=80&bg=eceff1&txtclr=607d8b&w=640&h=640', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
$superU->profile()->save($superUProfile);
// Administrator (User)
$adminU = User::create(['name' => 'Administrator', 'email' => 'admin@getwhiteboard.com', 'password' => bcrypt('password'), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
$adminUProfile = Profile::create(['user_id' => $adminU->id, 'username' => 'admin', 'salutation' => 'Mr', 'first_name' => 'Admin', 'middle_name' => '', 'last_name' => 'Istrator', 'nick_name' => 'Admin', 'date_of_birth' => '1990-05-16', 'address_line_1' => '78A Sackville Road', 'address_line_2' => '', 'address_line_3' => '', 'address_line_4' => '', 'address_city' => 'Hove', 'address_county' => 'East Sussex', 'address_postcode' => 'BN3 3HB', 'private_email_address' => 'admin@contest.dev', 'mobile_number' => '+44 (0) 7950 994 570', 'twitter_username' => 'admin', 'facebook_username' => 'admin', 'google_plus_username' => 'admin', 'instagram_username' => 'admin', 'profile_photo_url' => 'https://placeholdit.imgix.net/~text?txt=ADM&txtsize=90&bg=eceff1&txtclr=607d8b&w=640&h=640', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
$adminU->profile()->save($adminUProfile);
// Super Administrator (Role)
$superR = Role::create(['name' => 'super-admin', 'label' => 'Super Administrator']);
// Administrator (Role)
$adminR = Role::create(['name' => 'admin', 'label' => 'Administrator']);
// Student (Role)
$studentR = Role::create(['name' => 'student', 'label' => 'Student']);
//create 20 users
foreach (range(1, 20) as $index) {
$user_wbid = str_random(16);
$user_updated_at = $faker->dateTimeBetween($startDate = '-6 months', $endDate = 'now');
$user_created_at = $faker->dateTimeBetween($startDate = '-2 years', $endDate = $user_updated_at);
$user_name = $faker->firstName;
$user_username = strtolower($user_name . $faker->lastName);
$user_email = $user_username . $faker->companyEmail;
$user_dob = $faker->dateTimeBetween($startDate = '-25 years', $endDate = '-18 years');
$user = User::create(['wbid' => $user_wbid, 'name' => $user_name, 'dob' => $user_dob, 'email' => $user_email, 'username' => $user_username, 'password' => bcrypt('password'), 'key' => str_random(11), 'confirmed' => $faker->boolean(), 'created_at' => $user_created_at, 'updated_at' => $user_updated_at]);
$user->roles()->attach($studentR);
}
$michael->roles()->attach($studentR);
$sezer->roles()->attach($studentR);
$holly->roles()->attach($studentR);
$superU->roles()->attach($superR);
$adminU->roles()->attach($adminR);
$michael->roles()->attach($superR);
$sezer->roles()->attach($superR);
$michael->roles()->attach($adminR);
$sezer->roles()->attach($adminR);
$jane->roles()->attach($adminR);
}
示例10: create
protected function create($values)
{
$data = [];
foreach ($this->structure as $i => $key) {
$data[$key] = $values[$i];
}
Role::create($data);
}
示例11: run
public function run()
{
DB::table('roles')->delete();
$collection = [['role' => 'System'], ['role' => 'SysAdmin'], ['role' => 'SysExec'], ['role' => 'CompanyAdmin'], ['role' => 'TechAdmin'], ['role' => 'Support'], ['role' => 'Tech'], ['role' => 'Accounting'], ['role' => 'Seller'], ['role' => 'Tier1'], ['role' => 'Tier2'], ['role' => 'Tier3'], ['role' => 'Tier4'], ['role' => 'Vendor'], ['role' => 'Company Captain'], ['role' => 'Company First Officer'], ['role' => 'Company Engineer'], ['role' => 'Company Crew'], ['role' => 'Company Deadheader']];
foreach ($collection as $record) {
Role::create($record);
}
}
示例12: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Role::unguard();
$now = date('Y-m-d');
Role::create(['name' => 'admin', 'created_at' => $now, 'updated_at' => $now]);
Role::create(['name' => 'author', 'created_at' => $now, 'updated_at' => $now]);
Role::create(['name' => 'subscriber', 'created_at' => $now, 'updated_at' => $now]);
}
示例13: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
// see https://tuts.codingo.me/laravel-social-and-email-authentication
DB::table('roles')->delete();
Role::create(['name' => 'user']);
Role::create(['name' => 'administrator']);
}
示例14: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Role::create(['id' => 1, 'label' => 'admin', 'display_label' => 'Administrator']);
Role::create(['id' => 2, 'label' => 'guru', 'display_label' => 'Guru']);
Role::create(['id' => 3, 'label' => 'widyaiswara', 'display_label' => 'Widyaiswara']);
Role::create(['id' => 4, 'label' => 'evaluator', 'display_label' => 'Evaluator']);
Role::create(['id' => 5, 'label' => 'stakeholder', 'display_label' => 'Stakeholder']);
}
示例15: run
public function run()
{
DB::table('roles')->delete();
$collection = [['role' => 'System'], ['role' => 'SysAdmin'], ['role' => 'SysExec'], ['role' => 'CoAdmin'], ['role' => 'TechAdmin'], ['role' => 'Support'], ['role' => 'Tech'], ['role' => 'Accounting'], ['role' => 'Seller'], ['role' => 'Tier1'], ['role' => 'Tier2'], ['role' => 'Tier3'], ['role' => 'Tier4'], ['role' => 'Vendor']];
foreach ($collection as $record) {
Role::create($record);
}
}