本文整理汇总了PHP中Sentinel::getRoleRepository方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentinel::getRoleRepository方法的具体用法?PHP Sentinel::getRoleRepository怎么用?PHP Sentinel::getRoleRepository使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sentinel
的用法示例。
在下文中一共展示了Sentinel::getRoleRepository方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
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!');
}
示例3: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$roleAdmin = Sentinel::getRoleRepository()->createModel()->create(['name' => 'Admin', 'slug' => 'admin']);
$roleUser = Sentinel::getRoleRepository()->createModel()->create(['name' => 'User', 'slug' => 'user']);
$user = Sentinel::registerAndActivate(['email' => 'admin@admin.com', 'password' => 'admin']);
$roleAdmin->users()->attach($user);
}
示例4: run
public function run()
{
// we create the admin role
$admin = Sentinel::getRoleRepository()->createModel()->create(['slug' => 'admin', 'position' => 1]);
// we translate the translatable fields
$admin->translateOrNew('fr')->name = 'Administrateur';
$admin->translateOrNew('en')->name = 'Administrator';
// we give all permissions to the admin role
$permissions = [];
foreach (array_dot(config('permissions')) as $permission => $value) {
$permissions[$permission] = true;
}
$admin->permissions = $permissions;
// we save the changes
$admin->save();
// we create the moderator role
$mod = Sentinel::getRoleRepository()->createModel()->create(['slug' => 'moderator', 'position' => 2, 'permissions' => ['users.list' => true, 'users.view' => true, 'home.page.view' => true, 'home.slides.view' => true, 'news.page.view' => true, 'news.create' => true, 'news.view' => true, 'news.update' => true, 'schedules' => true, 'schedules.page.view' => true, 'schedules.create' => true, 'schedules.view' => true, 'schedules.update' => true, 'schedules.delete' => true, 'registration.page.view' => true, 'registration.prices.create' => true, 'registration.prices.view' => true, 'registration.prices.update' => true, 'registration.prices.delete' => true, 'partners.list' => true, 'partners.view' => true]]);
// we translate the translatable fields
$mod->translateOrNew('fr')->name = 'Modérateur';
$mod->translateOrNew('en')->name = 'Moderator';
$mod->save();
// we create the moderator role
$mod = Sentinel::getRoleRepository()->createModel()->create(['slug' => 'coach', 'position' => 3, 'permissions' => ['users.list' => true, 'users.view' => true, 'home.page.view' => true, 'home.slides.view' => true, 'news.page.view' => true, 'news.create' => true, 'news.view' => true, 'news.update' => true, 'schedules' => true, 'schedules.page.view' => true, 'schedules.create' => true, 'schedules.view' => true, 'schedules.update' => true, 'schedules.delete' => true, 'registration.page.view' => true, 'registration.prices.create' => true, 'registration.prices.view' => true, 'registration.prices.update' => true, 'registration.prices.delete' => true, 'partners.list' => true, 'partners.view' => true]]);
// we translate the translatable fields
$mod->translateOrNew('fr')->name = 'Coach';
$mod->translateOrNew('en')->name = 'Coach';
$mod->save();
// we create the user role
$member = Sentinel::getRoleRepository()->createModel()->create(['slug' => 'user', 'position' => 4]);
// we translate the translatable fields
$member->translateOrNew('fr')->name = 'Utilisateur';
$member->translateOrNew('en')->name = 'User';
$member->save();
}
示例5: run
public function run()
{
try {
$role = \Sentinel::getRoleRepository()->createModel()->create(['name' => 'Administrator', 'slug' => 'administrator']);
} catch (\Exception $e) {
}
}
示例6: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$superuser = ['accommodation.store' => true, 'accommodation.show' => true, 'accommodation.update' => true, 'accommodation.destroy' => true, 'conference.store' => true, 'conference.show' => true, 'conference.update' => true, 'conference.destroy' => true, 'conference_manager.store' => true, 'conference_manager.show' => true, 'conference_manager.destroy' => true, 'conference_attendee.show' => true, 'conference_attendee.update' => true, 'conference_attendee.destroy' => true, 'conference_vehicle.store' => true, 'conference_vehicle.show' => true, 'conference_vehicle.update' => true, 'conference_vehicle.destroy' => true, 'event.status' => true, 'event.store' => true, 'event.show' => true, 'event.update' => true, 'event.destroy' => true, 'event_manager.store' => true, 'event_manager.show' => true, 'event_manager.destroy' => true, 'event_attendee.show' => true, 'event_attendee.update' => true, 'event_attendee.destroy' => true, 'event_vehicle.store' => true, 'event_vehicle.show' => true, 'event_vehicle.update' => true, 'event_vehicle.destroy' => true, 'item.store' => true, 'item.show' => true, 'item.update' => true, 'item.destroy' => true, 'profile.store' => true, 'profile.show' => true, 'profile.update' => true, 'profile.destroy' => true, 'role.store' => true, 'role.show' => true, 'role.update' => true, 'role.destroy' => true, 'room.store' => true, 'room.show' => true, 'room.update' => true, 'room.destroy' => true, 'user.show' => true, 'user.update' => true, 'user.destroy' => true, 'vehicle.store' => true, 'vehicle.show' => true, 'vehicle.update' => true, 'vehicle.destroy' => true];
$conferenceManager = $superuser;
$conferenceManager['role.store'] = false;
$conferenceManager['role.show'] = false;
$conferenceManager['role.update'] = false;
$conferenceManager['role.destroy'] = false;
$eventManager = $conferenceManager;
$eventManager['accommodation.store'] = false;
$eventManager['accommodation.update'] = false;
$eventManager['accommodation.destroy'] = false;
$eventManager['conference.store'] = false;
$eventManager['conference.update'] = false;
$eventManager['conference.destroy'] = false;
$eventManager['conference_manager.store'] = false;
$eventManager['conference_manager.destroy'] = false;
$eventManager['conference_attendee.update'] = false;
$eventManager['conference_attendee.destroy'] = false;
$eventManager['conference_vehicle.store'] = false;
$eventManager['conference_vehicle.update'] = false;
$eventManager['conference_vehicle.destroy'] = false;
$eventManager['item.store'] = false;
$eventManager['item.update'] = false;
$eventManager['item.destroy'] = false;
$eventManager['room.store'] = false;
$eventManager['room.update'] = false;
$eventManager['room.destroy'] = false;
$regularUser = ['accommodation.store' => false, 'accommodation.show' => false, 'accommodation.update' => false, 'accommodation.destroy' => false, 'conference.store' => false, 'conference.show' => true, 'conference.update' => false, 'conference.destroy' => false, 'conference_manager.store' => false, 'conference_manager.show' => false, 'conference_manager.destroy' => false, 'conference_attendee.show' => true, 'conference_attendee.update' => true, 'conference_attendee.destroy' => false, 'conference_vehicle.store' => false, 'conference_vehicle.show' => false, 'conference_vehicle.update' => false, 'conference_vehicle.destroy' => false, 'event.store' => false, 'event.show' => true, 'event.update' => false, 'event.destroy' => false, 'event_manager.store' => false, 'event_manager.show' => false, 'event_manager.destroy' => false, 'event_attendee.show' => true, 'event_attendee.update' => true, 'event_attendee.destroy' => false, 'event_vehicle.store' => false, 'event_vehicle.show' => false, 'event_vehicle.update' => false, 'event_vehicle.destroy' => false, 'item.store' => false, 'item.show' => false, 'item.update' => false, 'item.destroy' => false, 'profile.store' => true, 'profile.show' => true, 'profile.update' => true, 'profile.destroy' => true, 'role.store' => false, 'role.show' => false, 'role.update' => false, 'role.destroy' => false, 'room.store' => false, 'room.show' => false, 'room.update' => false, 'room.destroy' => false, 'user.show' => false, 'user.update' => false, 'user.destroy' => false, 'vehicle.store' => false, 'vehicle.show' => false, 'vehicle.update' => false, 'vehicle.destroy' => false];
Sentinel::getRoleRepository()->createModel()->create(['slug' => 'system administrator', 'name' => 'System Administrator', 'permissions' => $superuser]);
Sentinel::getRoleRepository()->createModel()->create(['slug' => 'conference manager', 'name' => 'Conference Manager', 'permissions' => $conferenceManager]);
Sentinel::getRoleRepository()->createModel()->create(['slug' => 'event manager', 'name' => 'Event Manager', 'permissions' => $eventManager]);
Sentinel::getRoleRepository()->createModel()->create(['slug' => 'regular user', 'name' => 'Regular User', 'permissions' => $regularUser]);
}
示例7: render
public function render()
{
$this->_shareData();
if (!\Sentinel::hasAccess($this->permissions['view'])) {
return view('eztool::no_permission');
}
$roles = \Sentinel::getRoleRepository()->all();
$permissions = Permission::whereNull('parent')->orderBy('order')->get();
return view('eztool::acl_manager.render')->with('roles', $roles)->with('permission_list', $permissions);
}
示例8: _createUserRole
private function _createUserRole()
{
// we create the admin role
$operator = \Sentinel::getRoleRepository()->createModel()->create(['slug' => 'user', 'position' => 2]);
// we translate the translatable fields
$operator->translateOrNew('fr')->name = 'Utilisateur';
$operator->translateOrNew('en')->name = 'User';
// we save the changes
$operator->save();
return $operator;
}
示例9: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Sentinel::registerAndActivate(array('email' => 'admin@app.com', 'password' => '123456', 'first_name' => 'Admin', 'last_name' => 'App'));
$admin_role = Sentinel::getRoleRepository()->createModel()->create(array('name' => 'Admin', 'slug' => 'admin', 'permissions' => array('admin' => true, 'users' => true)));
$user_role = Sentinel::getRoleRepository()->createModel()->create(array('name' => 'Users', 'slug' => 'user', 'permissions' => array('admin' => false, 'users' => true)));
// Assign user permissions
$credentials = ['login' => 'admin@app.com'];
$admin_user = Sentinel::findUserByCredentials($credentials);
$admin_role = Sentinel::findRoleBySlug('admin');
$admin_role->users()->attach($admin_user);
}
示例10: run
public function run()
{
DB::table('users')->truncate();
// Using truncate function so all info will be cleared when re-seeding.
DB::table('roles')->truncate();
DB::table('role_users')->truncate();
$admin = Sentinel::registerAndActivate(array('email' => 'admin@admin.com', 'password' => "admin", 'first_name' => 'John', 'last_name' => 'Doe'));
$adminRole = Sentinel::getRoleRepository()->createModel()->create(['name' => 'Admin', 'slug' => 'admin', 'permissions' => array('admin' => 1)]);
Sentinel::getRoleRepository()->createModel()->create(['name' => 'User', 'slug' => 'user']);
$admin->roles()->attach($adminRole);
}
示例11: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$admin = ['email' => 'admin@admin.com', 'password' => 'adminadmin'];
$adminUser = Sentinel::registerAndActivate($admin);
$role = ['name' => 'Администратор', 'slug' => 'admin', 'permissions' => ['admin' => true]];
$adminRole = Sentinel::getRoleRepository()->createModel()->fill($role)->save();
$adminUser->roles()->attach($adminRole);
$role = ['name' => 'Пользователь', 'slug' => 'user'];
$userRole = Sentinel::getRoleRepository()->createModel()->fill($role)->save();
$role = ['name' => 'Забанен', 'slug' => 'banned'];
$banRole = Sentinel::getRoleRepository()->createModel()->fill($role)->save();
}
示例12: run
public function run()
{
$admin = Sentinel::registerAndActivate(array('email' => 'admin@admin.com', 'password' => 'admin', 'first_name' => 'John', 'last_name' => 'Doe', 'status' => 1));
$adminRole = Sentinel::getRoleRepository()->createModel()->create(['name' => 'Admin', 'slug' => 'admin', 'permissions' => array('admin' => 1)]);
Base::getSettingsRepository()->createModel()->create(['friendly_name' => 'SITE_NAME', 'name' => 'Website name', 'value' => 'John Doe\'s website', 'description' => 'Website name']);
Base::getSettingsRepository()->createModel()->create(['friendly_name' => 'USER_REGISTRATION', 'name' => 'User registration status', 'value' => '1', 'description' => '/*
* 0 - Disabled
* 1 - Enabled and no activation
* 2 - User activation
* 3 - Admin activation
*/']);
$admin->roles()->attach($adminRole);
}
示例13: 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) {
}
}
示例14: run
public function run()
{
DB::table('users')->truncate();
DB::table('roles')->truncate();
DB::table('role_users')->truncate();
$role = ['name' => 'Administrator', 'slug' => 'administrator', 'permissions' => ['admin' => true]];
$adminRole = Sentinel::getRoleRepository()->createModel()->fill($role)->save();
$subscribersRole = ['name' => 'Subscribers', 'slug' => 'subscribers'];
Sentinel::getRoleRepository()->createModel()->fill($subscribersRole)->save();
$admin = ['email' => 'admin@example.com', 'password' => 'password'];
$users = [['email' => 'demo1@example.com', 'password' => 'demo123'], ['email' => 'demo2@example.com', 'password' => 'demo123'], ['email' => 'demo3@example.com', 'password' => 'demo123']];
$adminUser = Sentinel::registerAndActivate($admin);
$adminUser->roles()->attach($adminRole);
foreach ($users as $user) {
Sentinel::registerAndActivate($user);
}
}
示例15: _createUserRole
private function _createUserRole()
{
// we create the admin role
$user_role = \Sentinel::getRoleRepository()->createModel()->create(['slug' => 'user', 'position' => 2]);
// we translate the translatable fields
$user_role->translateOrNew('fr')->name = 'Utilisateur';
$user_role->translateOrNew('en')->name = 'User';
// we give all permissions to the admin role
$permissions = [];
foreach (array_dot(config('permissions')) as $permission => $value) {
$permissions[$permission] = true;
}
$user_role->permissions = $permissions;
// we save the changes
$user_role->save();
return $user_role;
}