本文整理汇总了PHP中Sentinel::findRoleByName方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentinel::findRoleByName方法的具体用法?PHP Sentinel::findRoleByName怎么用?PHP Sentinel::findRoleByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sentinel
的用法示例。
在下文中一共展示了Sentinel::findRoleByName方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
for ($i = 4; $i < 20; $i++) {
$users[] = ['email' => 'demo' . $i . '@example.com', 'password' => 'demo123', 'username' => 'AAA00' . $i, 'username_upline' => 'AAA001', 'first_name' => 'Member ke-' . $i];
}
// $users = [
// [
// 'email' => 'demo4@example.com',
// 'password' => 'demo123',
// 'username' => 'AAA004',
// 'username_upline' => 'AAA001',
// ],
// [
// 'email' => 'demo5@example.com',
// 'password' => 'demo123',
// 'username' => 'AAA005',
// 'username_upline' => 'AAA001',
// ],
// [
// 'email' => 'demo6@example.com',
// 'password' => 'demo123',
// 'username' => 'AAA006',
// 'username_upline' => 'AAA001',
// ],
// ];
$role = Sentinel::findRoleByName('Members');
//dibuat dulu bila blm ada Role nya
foreach ($users as $user) {
$newUser = Sentinel::registerAndActivate($user);
//$newUser = Sentinel::findById($user->id);
$role->users()->attach($newUser);
}
Model::reguard();
}
示例2: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// Hapus isi table users, groups, users_groups dan throttle
DB::table('role_users')->delete();
DB::table('roles')->delete();
DB::table('users')->delete();
DB::table('throttle')->delete();
//create role administrator
$role = Sentinel::getRoleRepository()->createModel()->create(['name' => 'Administrators', 'slug' => 'administrators']);
//create role regulars
$role = Sentinel::getRoleRepository()->createModel()->create(['name' => 'Regulars', 'slug' => 'regulars']);
//create user admin and activate
$credentials = ['email' => 'admin@enter.id', 'password' => 'enter'];
$user = Sentinel::registerAndActivate($credentials);
//create user user and activate
$credentials = ['email' => 'user@example.com', 'password' => 'enter'];
$user = Sentinel::registerAndActivate($credentials);
// assign user to a role
$credentials = ['login' => 'admin@example.com'];
$user = Sentinel::findByCredentials($credentials);
//$user = Sentinel::findById(1);
$role = Sentinel::findRoleByName('Administrators');
$role->users()->attach($user);
$credentials = ['login' => 'user@example.com'];
$user = Sentinel::findByCredentials($credentials);
//$user = Sentinel::findById(1);
$role = Sentinel::findRoleByName('Regulars');
$role->users()->attach($user);
}
示例3: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('role_users')->delete();
$userUser = Sentinel::findByCredentials(['login' => 'user@user.com']);
$adminUser = Sentinel::findByCredentials(['login' => 'admin@admin.com']);
$userRole = Sentinel::findRoleByName('Users');
$adminRole = Sentinel::findRoleByName('Admins');
// Assign the roles to the users
$userRole->users()->attach($userUser);
$adminRole->users()->attach($adminUser);
$this->command->info('Users assigned to roles seeded!');
}
示例4: run
public function run()
{
try {
$role = \Sentinel::findRoleByName('Administrator');
$credentials = ['email' => 'admin@soa.backend', 'password' => 'password'];
$user = \Sentinel::create($credentials);
$role->users()->attach($user);
$activation = \Activation::create($user);
$activation_complete = \Activation::complete($user, $activation->code);
} catch (\Exception $e) {
}
}
示例5: is_admin
/**
* extending hieu-le/active function
*
* @param int $user_id
*
* @return bool
*/
function is_admin($user_id = null)
{
if ($user_id) {
$user = Sentinel::findById($user_id);
} else {
if (Sentinel::check()) {
$user = Sentinel::getUser();
} else {
return false;
}
}
$admin = Sentinel::findRoleByName('Administrator');
return $user && $user->inRole($admin);
}
示例6: run
public function run()
{
try {
$role = \Sentinel::getRoleRepository()->createModel()->create(['name' => 'Administrator', 'slug' => 'administrator']);
$role = \Sentinel::findRoleByName('Administrator');
$role->permissions = ['superadmin' => true, 'controlpanel' => true, 'admin.users.view' => true, 'admin.users.create' => true, 'admin.users.edit' => true, 'admin.users.destroy' => true, 'admin.roles.view' => true, 'admin.roles.create' => true, 'admin.roles.edit' => true, 'admin.roles.destroy' => true];
$role->save();
$credentials = ['email' => 'admin@soa.backend', 'password' => 'password'];
$user = \Sentinel::create($credentials);
$role->users()->attach($user);
$activation = \Activation::create($user);
$activation_complete = \Activation::complete($user, $activation->code);
} catch (\Exception $e) {
}
}
示例7: run
public function run()
{
try {
$permissions = ['superadmin' => ['default' => true, 'description' => 'Super Admin', 'group_name' => 'admin::lang.permission.without_group'], 'controlpanel' => ['default' => true, 'description' => 'Access to the Control Panel', 'group_name' => 'admin::lang.permission.without_group'], 'admin.users.view' => ['default' => true, 'description' => 'View Users', 'group_name' => 'admin::lang.permission.without_group'], 'admin.users.create' => ['default' => true, 'description' => 'Create Users', 'group_name' => 'admin::lang.permission.without_group'], 'admin.users.edit' => ['default' => true, 'description' => 'Edit Users', 'group_name' => 'admin::lang.permission.without_group'], 'admin.users.destroy' => ['default' => true, 'description' => 'Delete Users', 'group_name' => 'admin::lang.permission.without_group'], 'admin.roles.view' => ['default' => true, 'description' => 'View Roles', 'group_name' => 'admin::lang.permission.without_group'], 'admin.roles.create' => ['default' => true, 'description' => 'Create Roles', 'group_name' => 'admin::lang.permission.without_group'], 'admin.roles.edit' => ['default' => true, 'description' => 'Edit Roles', 'group_name' => 'admin::lang.permission.without_group'], 'admin.roles.destroy' => ['default' => true, 'description' => 'Delete Roles', 'group_name' => 'admin::lang.permission.without_group'], 'admin.permissions.view' => ['default' => true, 'description' => 'View Permissions', 'group_name' => 'admin::lang.permission.without_group'], 'admin.permissions.create' => ['default' => true, 'description' => 'Create Permissions', 'group_name' => 'admin::lang.permission.without_group'], 'admin.permissions.edit' => ['default' => true, 'description' => 'Edit Permissions', 'group_name' => 'admin::lang.permission.without_group'], 'admin.permissions.destroy' => ['default' => true, 'description' => 'Delete Permissions', 'group_name' => 'admin::lang.permission.without_group']];
//create records
foreach ($permissions as $key => $permission) {
PermissionModel::create(['value' => $key, 'description' => $permission['description'], 'group_name' => $permission['group_name']]);
}
$role = \Sentinel::findRoleByName('Administrator');
//assign permissions to role
foreach ($permissions as $key => $permission) {
$role->addPermission($key, $permission['default']);
}
$role->save();
} catch (\Exception $e) {
}
}
示例8: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
# User Seeder
Sentinel::registerAndActivate(['email' => 'user@user.com', 'password' => 'user123', 'first_name' => 'علی', 'last_name' => 'شفیعی', 'address1' => 'مجیدیه شمالی نرسیده به میدان سرباز کوچه شهید داوود علی بخشی پلاک 55 طبقه اول', 'address2' => 'سعادت آباد، کوی فراز شماره 86 بلوک 4 طبقه دوم واحد 4', 'address3' => 'سعدی جنوبی کوچه بانک تجارت پلاک 3 طبقه دوم']);
Sentinel::registerAndActivate(['email' => 'admin@admin.com', 'password' => 'admin123', 'first_name' => 'مجید', 'last_name' => 'نورعلی', 'address1' => 'مجیدیه شمالی نرسیده به میدان سرباز کوچه شهید داوود علی بخشی پلاک 55 طبقه اول', 'address2' => 'سعادت آباد، کوی فراز شماره 86 بلوک 4 طبقه دوم واحد 4', 'address3' => 'سعدی جنوبی کوچه بانک تجارت پلاک 3 طبقه دوم']);
$this->command->info('Users seeded!');
# Role Seeder
DB::table('roles')->delete();
Sentinel::getRoleRepository()->createModel()->create(['name' => 'users', 'slug' => 'users']);
Sentinel::getRoleRepository()->createModel()->create(['name' => 'admins', 'slug' => 'admins']);
$this->command->info('Roles seeded!');
# User Role Seeder
DB::table('role_users')->delete();
$user = Sentinel::findByCredentials(['login' => 'user@user.com']);
$admin = Sentinel::findByCredentials(['login' => 'admin@admin.com']);
$userRole = Sentinel::findRoleByName('users');
$adminRole = Sentinel::findRoleByName('admins');
$userRole->users()->attach($user);
$adminRole->users()->attach($admin);
$this->command->info('Users assigned to roles seeded!');
# Categories Table Seeder
DB::table('cats')->delete();
DB::table('cats')->insert([['title' => 'کاغذ'], ['title' => 'زینک'], ['title' => 'مرکب']]);
$this->command->info('Categories Table Seeded.');
# Orders Table Seeder
DB::table('orders')->delete();
DB::table('orders')->insert([['user_id' => '2', 'sum' => '208600', 'address' => 'سعدی جنوبی کوچه بانک تجارت پلاک 3 طبقه دوم', 'status' => '1'], ['user_id' => '2', 'sum' => '145500', 'address' => 'مجیدیه شمالی نرسیده به میدان سرباز کوچه شهید داوود علی بخشی پلاک 55 طبقه اول', 'status' => '0'], ['user_id' => '2', 'sum' => '650000', 'address' => 'سعدی جنوبی کوچه بانک تجارت پلاک 3 طبقه دوم', 'status' => '1']]);
$this->command->info('Orders Table Seeded.');
# Products Table Seeder
DB::table('products')->delete();
DB::table('products')->insert([['name' => 'کاغذ A4 Copymax', 'des' => 'کاغذ A4 Copymax کاغذ A4 Copymax کاغذ A4 Copymax', 'cat_id' => 1, 'size' => '210x297', 'weight' => 80, 'pic' => 'copimax.jpg', 'active' => 1], ['name' => 'کاغذ A4 DoubleA', 'des' => 'کاغذ A4 DoubleA کاغذ A4 DoubleA کاغذ A4 DoubleA', 'cat_id' => 1, 'size' => '210x297', 'weight' => 80, 'pic' => 'doublea.jpg', 'active' => 1], ['name' => 'زینک GTO', 'des' => 'زینک GTO زینک GTO زینک GTO', 'cat_id' => 2, 'size' => '326x256', 'weight' => 213, 'pic' => 'zinc1.jpg', 'active' => 1], ['name' => 'کاغذ JKcmax', 'des' => 'کاغذ JKcmax کاغذ JKcmax کاغذ JKcmax', 'cat_id' => 1, 'size' => '210x297', 'weight' => 80, 'pic' => 'jkcmax.jpg', 'active' => 1], ['name' => 'زینک دو ورقی', 'des' => 'زینک دو ورقی زینک دو ورقی زینک دو ورقی', 'cat_id' => 2, 'size' => '544x456', 'weight' => 253, 'pic' => 'zinc2.jpg', 'active' => 1], ['name' => 'زینگ دو و نیم ورقی اسپید', 'des' => 'زینگ دو و نیم ورقی اسپید زینگ دو و نیم ورقی اسپید زینگ دو و نیم ورقی اسپید', 'cat_id' => 2, 'size' => '700x500', 'weight' => 315, 'pic' => 'zinc3.jpg', 'active' => 1], ['name' => 'زینگ چهار و نیم ورقی', 'des' => 'زینگ چهار و نیم ورقی زینگ چهار و نیم ورقی زینگ چهار و نیم ورقی', 'cat_id' => 2, 'size' => '700x500', 'weight' => 315, 'pic' => 'zinc4.jpg', 'active' => 1], ['name' => 'مرکب Huaguang', 'des' => 'مرکب Huaguang مرکب Huaguang مرکب Huaguang', 'cat_id' => 3, 'size' => '454', 'weight' => 4545, 'pic' => 'uv1.jpg', 'active' => 1], ['name' => 'مرکب Huaguang 1', 'des' => 'مرکب Huaguang 1 مرکب Huaguang 1 مرکب Huaguang 1', 'cat_id' => 3, 'size' => '4564', 'weight' => 345, 'pic' => 'uv2.jpg', 'active' => 1], ['name' => 'مرکب چاپ', 'des' => 'مرکب چاپ مرکب چاپ مرکب چاپ', 'cat_id' => 3, 'size' => '4564', 'weight' => 345, 'pic' => 'uv3.jpg', 'active' => 1]]);
$this->command->info('Products Seeded.');
# Units Table Seeder
DB::table('units')->delete();
DB::table('units')->insert([['title' => 'بسته'], ['title' => 'کارتن'], ['title' => 'بند'], ['title' => 'گالن'], ['title' => 'جعبه'], ['title' => 'پالت']]);
$this->command->info('Units Table Seeded.');
# Unit Cats Table Seeder
DB::table('unit_cats')->delete();
DB::table('unit_cats')->insert([['cat_id' => '1', 'unit_id' => '1'], ['cat_id' => '1', 'unit_id' => '2'], ['cat_id' => '2', 'unit_id' => '1'], ['cat_id' => '3', 'unit_id' => '4'], ['cat_id' => '2', 'unit_id' => '6'], ['cat_id' => '3', 'unit_id' => '5']]);
$this->command->info('Unit_Cats Table Seeded.');
# Price Table Seeder
DB::table('prices')->delete();
DB::table('prices')->insert([['product_id' => '1', 'unit_id' => '1', 'price' => '100000'], ['product_id' => '1', 'unit_id' => '2', 'price' => '110000'], ['product_id' => '2', 'unit_id' => '1', 'price' => '200000'], ['product_id' => '2', 'unit_id' => '2', 'price' => '210000'], ['product_id' => '3', 'unit_id' => '1', 'price' => '300000'], ['product_id' => '3', 'unit_id' => '6', 'price' => '333000'], ['product_id' => '4', 'unit_id' => '1', 'price' => '400000'], ['product_id' => '4', 'unit_id' => '2', 'price' => '410000'], ['product_id' => '5', 'unit_id' => '1', 'price' => '500000'], ['product_id' => '5', 'unit_id' => '6', 'price' => '555000'], ['product_id' => '6', 'unit_id' => '1', 'price' => '600000'], ['product_id' => '6', 'unit_id' => '6', 'price' => '666000'], ['product_id' => '7', 'unit_id' => '1', 'price' => '700000'], ['product_id' => '7', 'unit_id' => '6', 'price' => '777000'], ['product_id' => '8', 'unit_id' => '4', 'price' => '800000'], ['product_id' => '8', 'unit_id' => '5', 'price' => '888000'], ['product_id' => '9', 'unit_id' => '4', 'price' => '900000'], ['product_id' => '9', 'unit_id' => '5', 'price' => '999000'], ['product_id' => '10', 'unit_id' => '4', 'price' => '910000'], ['product_id' => '10', 'unit_id' => '5', 'price' => '919000']]);
$this->command->info('Prices Table Seeded.');
}
示例9: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('roles')->delete();
DB::table('users')->delete();
DB::table('role_users')->delete();
$roles = ['administradores' => ['name' => 'Administradores', 'slug' => 'administradores', 'permissions' => ['admin.system' => true]], 'invitados' => ['name' => 'Invitados', 'slug' => 'invitados']];
foreach ($roles as $role) {
Sentinel::getRoleRepository()->createModel()->fill($role)->save();
}
$this->command->info('Roles seeded!');
$users = [['email' => 'administrador@jenion.com.ve', 'password' => '12345678', 'first_name' => 'Administrador', 'last_name' => 'Jenion', 'nickname' => 'admjenion'], ['email' => 'invitado@jenion.com.ve', 'password' => '12345678', 'first_name' => 'Invitado', 'last_name' => 'Jenion', 'nickname' => 'invjenion']];
foreach ($users as $user) {
Sentinel::registerAndActivate($user);
}
$this->command->info('Users seeded!');
$admUser = Sentinel::findByCredentials(['login' => 'administrador@jenion.com.ve']);
$invUser = Sentinel::findByCredentials(['login' => 'invitado@jenion.com.ve']);
$invGroup = Sentinel::findRoleByName('Invitados');
$admGroup = Sentinel::findRoleByName('Administradores');
// Assign the groups to the users
$invGroup->users()->attach($invUser);
$admGroup->users()->attach($admUser);
$this->command->info('Users assigned to role seeded!');
}
示例10: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$SYSTEM_ADMINISTRATOR = Sentinel::findRoleByName('System Administrator');
$CONFERENCE_MANAGER = Sentinel::findRoleByName('Conference Manager');
$EVENT_MANAGER = Sentinel::findRoleByName('Event Manager');
$REGULAR_USER = Sentinel::findRoleByName('Regular User');
// ---------------------------------------------------------------------
// USER 1
// ---------------------------------------------------------------------
$user = ['username' => 'admin', 'email' => 'admin@huddle.com', 'password' => 'password1'];
$user = Sentinel::registerAndActivate($user);
$role = $SYSTEM_ADMINISTRATOR;
$role->users()->attach($user);
$user->permissions = $role->permissions;
$user->save();
$profile = ['is_owner' => true, 'email' => $user->email, 'phone' => '6041234567', 'first_name' => 'System', 'last_name' => 'Administrator', 'city' => 'Vancouver', 'country' => 'Canada', 'gender' => 'male'];
$profile = new Profile($profile);
$profile->user()->associate($user);
$profile->save();
// ---------------------------------------------------------------------
// USER 2
// ---------------------------------------------------------------------
$user = ['username' => 'haniel', 'email' => 'haniel@huddle.com', 'password' => 'password1'];
$user = Sentinel::registerAndActivate($user);
$role = $CONFERENCE_MANAGER;
$role->users()->attach($user);
$user->permissions = $role->permissions;
$user->save();
$profile = ['is_owner' => true, 'email' => $user->email, 'phone' => '6041234567', 'first_name' => 'Haniel', 'last_name' => 'Martino', 'city' => 'Vancouver', 'country' => 'Canada', 'gender' => 'male'];
$profile = new Profile($profile);
$profile->user()->associate($user);
$profile->save();
// ---------------------------------------------------------------------
// UESR 3
// ---------------------------------------------------------------------
$user = ['username' => 'viggy', 'email' => 'viggy@huddle.com', 'password' => 'password1'];
$user = Sentinel::registerAndActivate($user);
$role = $CONFERENCE_MANAGER;
$role->users()->attach($user);
$user->permissions = $role->permissions;
$user->save();
$profile = ['is_owner' => true, 'email' => $user->email, 'phone' => '6041234567', 'first_name' => 'Vincent', 'last_name' => 'Lore', 'city' => 'Vancouver', 'country' => 'Canada', 'birthdate' => '1993-02-08', 'gender' => 'male'];
$profile = new Profile($profile);
$profile->user()->associate($user);
$profile->save();
// ---------------------------------------------------------------------
// USER 4
// ---------------------------------------------------------------------
$user = ['username' => 'gabby', 'email' => 'gabby@huddle.com', 'password' => 'password1'];
$user = Sentinel::registerAndActivate($user);
$role = $CONFERENCE_MANAGER;
$role->users()->attach($user);
$user->permissions = $role->permissions;
$user->save();
$profile = ['is_owner' => true, 'email' => $user->email, 'phone' => '6041234567', 'first_name' => 'Gabriela', 'last_name' => 'Hernandez', 'city' => 'Vancouver', 'country' => 'Canada', 'birthdate' => '1993-02-16', 'gender' => 'female'];
$profile = new Profile($profile);
$profile->user()->associate($user);
$profile->save();
// ---------------------------------------------------------------------
// USER 5
// ---------------------------------------------------------------------
$user = ['username' => 'james', 'email' => 'james@huddle.com', 'password' => 'password1'];
$user = Sentinel::registerAndActivate($user);
$role = $CONFERENCE_MANAGER;
$role->users()->attach($user);
$user->permissions = $role->permissions;
$user->save();
$profile = ['is_owner' => true, 'email' => $user->email, 'phone' => '6041234567', 'first_name' => 'James', 'last_name' => 'Ma', 'city' => 'Vancouver', 'country' => 'Canada', 'birthdate' => '1992-01-23', 'gender' => 'male'];
$profile = new Profile($profile);
$profile->user()->associate($user);
$profile->save();
// ---------------------------------------------------------------------
// USER 6
// ---------------------------------------------------------------------
$user = ['username' => 'martin', 'email' => 'martin@huddle.com', 'password' => 'password1'];
$user = Sentinel::registerAndActivate($user);
$role = $CONFERENCE_MANAGER;
$role->users()->attach($user);
$user->permissions = $role->permissions;
$user->save();
$profile = ['is_owner' => true, 'email' => $user->email, 'phone' => '6041234567', 'first_name' => 'Martin', 'last_name' => 'Tsang', 'city' => 'Vancouver', 'country' => 'Canada', 'birthdate' => '1993-05-15', 'gender' => 'male'];
$profile = new Profile($profile);
$profile->user()->associate($user);
$profile->save();
// ---------------------------------------------------------------------
// USER 7
// ---------------------------------------------------------------------
$user = ['username' => 'chris', 'email' => 'chris@huddle.com', 'password' => 'password1'];
$user = Sentinel::registerAndActivate($user);
$role = $CONFERENCE_MANAGER;
$role->users()->attach($user);
$user->permissions = $role->permissions;
$user->save();
$user->permissions = $role->permissions;
$user->save();
//.........这里部分代码省略.........
示例11: createAdminUserAndRole
protected function createAdminUserAndRole()
{
$permissions = ['superadmin' => ['default' => true, 'description' => 'Super Admin'], 'controlpanel' => ['default' => true, 'description' => 'Access to the Control Panel'], 'admin.users.view' => ['default' => true, 'description' => 'View Users'], 'admin.users.create' => ['default' => true, 'description' => 'Create Users'], 'admin.users.edit' => ['default' => true, 'description' => 'Edit Users'], 'admin.users.destroy' => ['default' => true, 'description' => 'Delete Users'], 'admin.roles.view' => ['default' => true, 'description' => 'View Roles'], 'admin.roles.create' => ['default' => true, 'description' => 'Create Roles'], 'admin.roles.edit' => ['default' => true, 'description' => 'Edit Roles'], 'admin.roles.destroy' => ['default' => true, 'description' => 'Delete Roles'], 'admin.permissions.view' => ['default' => true, 'description' => 'View Permissions'], 'admin.permissions.create' => ['default' => true, 'description' => 'Create Permissions'], 'admin.permissions.edit' => ['default' => true, 'description' => 'Edit Permissions'], 'admin.permissions.destroy' => ['default' => true, 'description' => 'Delete Permissions']];
try {
//create admin user
$credentials = ['email' => 'admin@soa.backend', 'password' => 'password'];
$user = \Sentinel::create($credentials);
$activation = \Activation::create($user);
$activation_complete = \Activation::complete($user, $activation->code);
//create admin role
$role = \Sentinel::getRoleRepository()->createModel()->create(['name' => 'Administrator', 'slug' => 'administrator']);
$role = \Sentinel::findRoleByName('Administrator');
//add permissions to role
foreach ($permissions as $key => $permission) {
$role->addPermission($key, $permission['default']);
}
$role->save();
//attach admin user to admin role
$role->users()->attach($user);
$this->info('Admin Role and User created successfully.');
$this->addPermissions($permissions);
} catch (\Exception $e) {
$this->info('Something went wrong while creating Admin Role and User.');
$this->error($e);
}
}
示例12: createAdminUserAndRole
protected function createAdminUserAndRole()
{
try {
$role = \Sentinel::getRoleRepository()->createModel()->create(['name' => 'Administrator', 'slug' => 'administrator']);
$role = \Sentinel::findRoleByName('Administrator');
$role->permissions = ['superadmin' => true, 'controlpanel' => true, 'admin.users.view' => true, 'admin.users.create' => true, 'admin.users.edit' => true, 'admin.users.destroy' => true, 'admin.roles.view' => true, 'admin.roles.create' => true, 'admin.roles.edit' => true, 'admin.roles.destroy' => true];
$role->save();
$credentials = ['email' => 'admin@soa.backend', 'password' => 'password'];
$user = \Sentinel::create($credentials);
$role->users()->attach($user);
$activation = \Activation::create($user);
$activation_complete = \Activation::complete($user, $activation->code);
$this->info('Admin Role and User created successfully.');
} catch (\Exception $e) {
$this->info('Something went wrong while creating Admin Role and User.');
}
}
示例13: run
public function run()
{
$_user = Sentinel::register(['email' => 'admin@me.com', 'password' => 'abc123'], true);
$group = Sentinel::findRoleByName('Admin');
$group->users()->attach($_user);
}