本文整理汇总了PHP中Sentry::createGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentry::createGroup方法的具体用法?PHP Sentry::createGroup怎么用?PHP Sentry::createGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sentry
的用法示例。
在下文中一共展示了Sentry::createGroup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postUpdate
function postUpdate($id = 0, &$data)
{
$groupName = trim(Input::get('name'));
if ($id == 0) {
try {
// Create the group
$group = Sentry::createGroup(array('name' => $groupName));
$data['id'] = $group->id;
$data['status'] = TRUE;
} catch (\Cartalyst\Sentry\Groups\NameRequiredException $e) {
$data['message'] = "Vui lòng nhập tên nhóm";
} catch (\Cartalyst\Sentry\Groups\GroupExistsException $e) {
$data['message'] = "Tên nhóm đã tồn tại. Vui lòng nhập tên nhóm khác";
}
} else {
try {
// Find the group using the group id
$group = Sentry::findGroupById($id);
// Update the group details
$group->name = $groupName;
if ($group->save()) {
$data['status'] = TRUE;
}
} catch (\Cartalyst\Sentry\Groups\NameRequiredException $e) {
$data['message'] = "Vui lòng nhập tên nhóm";
} catch (\Cartalyst\Sentry\Groups\GroupExistsException $e) {
$data['message'] = "Tên nhóm đã tồn tại. Vui lòng nhập tên nhóm khác";
} catch (\Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
$data['message'] = "Nhóm không tồn tại";
}
}
}
示例2: run
public function run()
{
//Hapus isi table users, groups, users_groups dan Throttle
DB::table('users_groups')->delete();
DB::table('groups')->delete();
DB::table('users')->delete();
DB::table('throttle')->delete();
try {
//Membuat grup admin
$group = Sentry::createGroup(array('name' => 'admin', 'permissions' => array('admin' => 1)));
} catch (Cartalyst\Sentry\Groups\NameRequiredException $e) {
echo 'Name field is required';
} catch (Cartalyst\Sentry\Groups\GroupExistsException $e) {
echo 'Group already exists';
}
try {
//Membuat admin baru
$admin = Sentry::register(array('username' => 'admin', 'password' => 'admin', 'first_name' => 'Admin', 'last_name' => 'Koperasi'), true);
//Langsung diaktivasi
//Cari Group Admin
$adminGroup = Sentry::findGroupByName('admin');
//Masukkan user ke Group admin
$admin->addGroup($adminGroup);
} catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
echo 'Login field is required.';
} catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
echo 'Password field is required.';
} catch (Cartalyst\Sentry\Users\UserExistsException $e) {
echo 'User with this login already exists.';
} catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
echo 'Group was not found.';
}
}
示例3: run
public function run()
{
DB::table('users_groups')->delete();
DB::table('groups')->delete();
DB::table('users')->delete();
DB::table('throttle')->delete();
try {
//membuat group admin
$group = Sentry::createGroup(array('name' => 'admin', 'permissions' => array('admin' => 1)));
//membuat group guru
$guru = Sentry::createGroup(array('name' => 'guru', 'permissions' => array('guru' => 1)));
//membuat group siswa
$siswa = Sentry::createGroup(array('name' => 'siswa', 'permissions' => array('siswa' => 1)));
} catch (Cartalyst\Sentry\Groups\NameRequiredException $e) {
echo "Nama Group harus diisi";
} catch (Cartalyst\Sentry\Groups\GroupExistsException $e) {
echo "Group Sudah Ada";
}
try {
//membuat admin baru
$admin = Sentry::register(array('password' => 'admin123', 'username' => 'Admin'), true);
//cari group admin
$adminGroup = Sentry::findGroupByName('admin');
//masukan user ke group admin
$admin->addGroup($adminGroup);
} catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
echo "Field login harus diisi";
} catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
echo "Password harus diisi";
} catch (Cartalyst\Sentry\Users\UserExistsException $e) {
echo "User dengan akun ini sudah ada";
} catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
echo "Group tidak ada";
}
}
示例4: run
public function run()
{
DB::table('users_groups')->delete();
DB::table('groups')->delete();
DB::table('users')->delete();
DB::table('throttle')->delete();
try {
$group = Sentry::createGroup(array('name' => 'administrator', 'description' => 'Administrator', 'permissions' => array('admin' => 1)));
$group = Sentry::createGroup(array('name' => 'operator', 'description' => 'Operator', 'permissions' => array('operator' => 1)));
} catch (Cartalyst\Sentry\Groups\NameRequiredException $e) {
echo "Name file is Required";
} catch (Cartalyst\Sentry\Groups\GroupExistsException $e) {
echo "Group already exists";
}
try {
$admin = Sentry::register(array('email' => 'admin@mail.com', 'password' => 'admin', 'first_name' => 'Administrator', 'last_name' => 'IT KSA'), true);
$adminGroup = Sentry::findGroupByName('administrator');
$admin->addGroup($adminGroup);
$operator = Sentry::register(array('email' => 'antoniosaiful10@gmail.com', 'password' => '090996o9o9g6!@#', 'first_name' => 'Operator', 'last_name' => 'IT KSA'), true);
$operatorGroup = Sentry::findGroupByName('operator');
$operator->addGroup($operatorGroup);
} catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
echo "Login field is required";
} catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
echo "Password field is required";
} catch (Cartalyst\Sentry\Users\UserExistsException $e) {
echo "User with this login is Required";
} catch (Cartalyst\Sentry\Users\GroupNotFoundException $e) {
echo "Group was not found";
}
}
示例5: run
public function run()
{
DB::table('groups')->truncate();
$admin = Sentry::createGroup(array('name' => 'Manager', 'permissions' => []));
$staff = Sentry::createGroup(array('name' => 'Store Manager', 'permissions' => []));
$staff = Sentry::createGroup(array('name' => 'Sales Person', 'permissions' => []));
\Mualnuam\Permission::revoke();
}
示例6: createGroup
/**
* Create roles if they don't exist already
*
*/
protected function createGroup($name)
{
try {
$group = \Sentry::createGroup(['name' => $name, 'permissions' => ['superuser' => 1]]);
} catch (\Exception $e) {
// this group probably already exists... so ignore the exception
}
}
示例7: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// ID 1
$admin = \Sentry::register(['email' => env('ADMIN_EMAIL'), 'password' => env('ADMIN_PASSWORD'), 'timezone' => env('ADMIN_TIMEZONE')], true);
// ID 1
$adminGroup = \Sentry::createGroup(array('name' => 'Superuser', 'permissions' => array('superuser' => 1)));
$admin->addGroup($adminGroup);
}
示例8: run
public function run()
{
Sentry::createGroup(array('name' => 'Carga Inicial'));
Sentry::createGroup(array('name' => 'Trabajador Social'));
Sentry::createGroup(array('name' => 'Autorizador'));
Sentry::createGroup(array('name' => 'Administrador'));
//, 'permissions' => '{"superuser":1}'
}
示例9: run
public function run()
{
DB::table('groups')->delete();
Sentry::createGroup(array('name' => 'administrador', 'permissions' => array('admin' => 1, 'deeds_index' => 1, 'deeds_create' => 1, 'deeds_update' => 1, 'deeds_delete' => 1, 'agrarians_index' => 1, 'agrarians_create' => 1, 'agrarians_update' => 1, 'agrarians_delete' => 1, 'civils_index' => 1, 'civils_create' => 1, 'civils_update' => 1, 'civils_delete' => 1, 'penals_index' => 1, 'penals_create' => 1, 'penals_update' => 1, 'penals_delete' => 1, 'records_index' => 1, 'records_create' => 1, 'records_update' => 1, 'records_delete' => 1, 'notaries_index' => 1, 'notaries_create' => 1, 'notaries_update' => 1, 'notaries_delete' => 1, 'municipalities_index' => 1, 'municipalities_create' => 1, 'municipalities_update' => 1, 'municipalities_delete' => 1, 'users_index' => 1, 'users_create' => 1, 'users_update' => 1, 'users_delete' => 1, 'groups_index' => 1, 'groups_create' => 1, 'groups_update' => 1, 'groups_delete' => 1, 'profiles_index' => 1, 'profiles_create' => 1, 'profiles_update' => 1, 'profiles_delete' => 1, 'comments_index' => 1, 'comments_create' => 1, 'comments_update' => 1, 'comments_delete' => 1)));
Sentry::createGroup(array('name' => 'director', 'permissions' => array('admin' => 1, 'deeds_index' => 1, 'deeds_create' => 1, 'deeds_update' => 1, 'deeds_delete' => 1, 'agrarians_index' => 1, 'agrarians_create' => 1, 'agrarians_update' => 1, 'agrarians_delete' => 1, 'civils_index' => 1, 'civils_create' => 1, 'civils_update' => 1, 'civils_delete' => 1, 'penals_index' => 1, 'penals_create' => 1, 'penals_update' => 1, 'penals_delete' => 1, 'records_index' => 1, 'records_create' => 1, 'records_update' => 1, 'records_delete' => 1, 'notaries_index' => 1, 'notaries_create' => 1, 'notaries_update' => 1, 'notaries_delete' => 1, 'municipalities_index' => 1, 'municipalities_create' => 1, 'municipalities_update' => 1, 'municipalities_delete' => 1, 'users_index' => 1, 'users_create' => 1, 'users_update' => 1, 'users_delete' => 1, 'groups_index' => 1, 'groups_create' => 1, 'groups_update' => 1, 'groups_delete' => 1, 'profiles_index' => 1, 'profiles_create' => 1, 'profiles_update' => 1, 'profiles_delete' => 1, 'comments_index' => 1, 'comments_create' => 1, 'comments_update' => 1, 'comments_delete' => 1)));
Sentry::createGroup(array('name' => 'secretaria', 'permissions' => array('admin' => 1, 'deeds_index' => 1, 'deeds_create' => 1, 'deeds_update' => 1, 'deeds_delete' => 1, 'agrarians_index' => 1, 'agrarians_create' => 1, 'agrarians_update' => 1, 'agrarians_delete' => 1, 'civils_index' => 1, 'civils_create' => 1, 'civils_update' => 1, 'civils_delete' => 1, 'penals_index' => 1, 'penals_create' => 1, 'penals_update' => 1, 'penals_delete' => 1, 'records_index' => 1, 'records_create' => 1, 'records_update' => 1, 'records_delete' => 1, 'notaries_index' => 1, 'notaries_create' => 1, 'notaries_update' => 1, 'notaries_delete' => 1, 'municipalities_index' => 1, 'municipalities_create' => 1, 'municipalities_update' => 1, 'municipalities_delete' => 1, 'users_index' => 1, 'users_create' => 1, 'users_update' => 1, 'users_delete' => 1, 'groups_index' => 1, 'groups_create' => 1, 'groups_update' => 1, 'groups_delete' => 1, 'profiles_update' => 1, 'comments_index' => 1, 'comments_create' => 1, 'comments_update' => 1, 'comments_delete' => 1)));
Sentry::createGroup(array('name' => 'practicante', 'permissions' => array('admin' => 1, 'deeds_index' => 1, 'deeds_create' => 1, 'deeds_update' => 1, 'deeds_delete' => 1, 'agrarians_index' => 1, 'agrarians_create' => 1, 'agrarians_update' => 1, 'agrarians_delete' => 1, 'civils_index' => 1, 'civils_create' => 1, 'civils_update' => 1, 'civils_delete' => 1, 'penals_index' => 1, 'penals_create' => 1, 'penals_update' => 1, 'penals_delete' => 1, 'records_index' => 1, 'records_create' => 1, 'records_update' => 1, 'records_delete' => 1, 'notaries_index' => 1, 'notaries_create' => 1, 'notaries_update' => 1, 'notaries_delete' => 1, 'municipalities_index' => 1, 'municipalities_create' => 1, 'municipalities_update' => 1, 'municipalities_delete' => 1, 'profiles_update' => 1, 'comments_index' => 1, 'comments_create' => 1, 'comments_update' => 1, 'comments_delete' => 1)));
Sentry::createGroup(array('name' => 'usuario', 'permissions' => array('users' => 1, 'deeds_index' => 1, 'agrarians_index' => 1, 'civils_index' => 1, 'penals_index' => 1, 'records_index' => 1, 'notaries_index' => 1, 'municipalities_index' => 1, 'profiles_update' => 1, 'comments_index' => 1, 'comments_create' => 1, 'comments_update' => 1, 'comments_delete' => 1)));
}
示例10: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//创建用户组
Sentry::createGroup(array('name' => 'Admin', 'is_admin' => 1, 'permissions' => []));
Sentry::createGroup(array('name' => 'Guest', 'is_admin' => 0, 'permissions' => []));
$user = Sentry::createUser(array('email' => 'admin@admin.com', 'username' => 'admin', 'password' => '123456', 'activated' => true));
$adminGroup = Sentry::findGroupById(1);
$user->addGroup($adminGroup);
Uinfo::create(['uid' => $user->id]);
}
示例11: run
public function run()
{
DB::table('users')->delete();
DB::table('groups')->delete();
DB::table('users_groups')->delete();
$user = Sentry::createUser(array('username' => 'superadmin', 'password' => 'ad123min', 'first_name' => 'Super', 'last_name' => 'Administrator', 'activated' => 1));
$group = Sentry::createGroup(array('name' => 'Super Administrators', 'permissions' => array('superuser' => 1)));
// Assign user permissions
$userGroup = Sentry::findGroupById(1);
$user->addGroup($userGroup);
}
示例12: createSuperuser
/**
* Create new random superuser.
*
* @param string $password
*
* @return \VisualAppeal\Connect\User
*/
protected function createSuperuser($password = '123456')
{
$lastLogin = $this->faker->dateTime();
$admin = \Sentry::createUser(['email' => $this->faker->email, 'password' => $password, 'activated' => 1, 'activated_at' => $this->faker->dateTime($lastLogin), 'last_login' => $lastLogin, 'first_name' => $this->faker->firstName, 'last_name' => $this->faker->lastName]);
try {
$adminGroup = Sentry::findGroupById(1);
} catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
$adminGroup = Sentry::createGroup(['name' => 'Superuser', 'permissions' => ['superuser' => 1]]);
}
$admin->addGroup($adminGroup);
return $admin;
}
示例13: run
public function run()
{
// 清空数据
DB::table('users')->truncate();
DB::table('groups')->truncate();
DB::table('users_groups')->truncate();
//创建用户组
$group = Sentry::createGroup(array('name' => '管理员', 'permissions' => array('superuser' => '1')));
// 创建用户
$user = Sentry::createUser(array('email' => 'admin', 'password' => "123456", 'first_name' => 'admin', 'last_name' => '', 'activated' => 1));
//关联用户组
$user->addGroup($group);
}
示例14: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
//
try {
// Create the group
$group = Sentry::createGroup(array('name' => Input::get('name'), 'permissions' => is_array(Input::get('permissions')) ? array_fill_keys(Input::get('permissions'), 1) : array()));
return Redirect::route('admin.groups.index');
} catch (Cartalyst\Sentry\Groups\NameRequiredException $e) {
return Redirect::back()->withInput()->withErrors('Name field is required');
} catch (Cartalyst\Sentry\Groups\GroupExistsException $e) {
return Redirect::back()->withInput()->withErrors('Group already exists');
}
}
示例15: run
public function run()
{
DB::table('users')->delete();
DB::table('groups')->delete();
DB::table('users_groups')->delete();
Sentry::getUserProvider()->create(array('email' => 'admin@admin.com', 'password' => "admin", 'first_name' => 'Transport', 'last_name' => 'Social', 'activated' => 1));
Sentry::getGroupProvider()->create(array('name' => 'Admin', 'permissions' => array('admin' => 1)));
Sentry::createGroup(array('name' => 'Users', 'permissions' => array('admin' => 0, 'users' => 1)));
// Assign user permissions
$adminUser = Sentry::getUserProvider()->findByLogin('admin@admin.com');
$adminGroup = Sentry::getGroupProvider()->findByName('Admin');
$adminUser->addGroup($adminGroup);
}