當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Sentry::createGroup方法代碼示例

本文整理匯總了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";
         }
     }
 }
開發者ID:huycao,項目名稱:yoplatform,代碼行數:32,代碼來源:UserGroupAdminController.php

示例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.';
     }
 }
開發者ID:albertxiao,項目名稱:Koperasi,代碼行數:33,代碼來源:UserTableSeeder.php

示例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";
     }
 }
開發者ID:jamalapriadi,項目名稱:sia,代碼行數:35,代碼來源:SentrySeeder.php

示例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";
     }
 }
開發者ID:antoniosai,項目名稱:daily-activity-management,代碼行數:31,代碼來源:SentrySeeder.php

示例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();
 }
開發者ID:nurulimamnotes,項目名稱:point-of-sale,代碼行數:8,代碼來源:GroupTableSeeder.php

示例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
     }
 }
開發者ID:codesleeve,項目名稱:platform-core,代碼行數:12,代碼來源:Platform.php

示例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);
 }
開發者ID:rafaelvieiras,項目名稱:connect,代碼行數:13,代碼來源:AdminSeeder.php

示例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}'
 }
開發者ID:armandolazarte,項目名稱:sasyc,代碼行數:8,代碼來源:GruposTableSeeder.php

示例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)));
 }
開發者ID:hectorz11,項目名稱:laravel_sistema_art,代碼行數:9,代碼來源:GroupTableSeeder.php

示例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]);
 }
開發者ID:leebivip,項目名稱:laravel_cmp,代碼行數:15,代碼來源:SentryInitSeeder.php

示例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);
 }
開發者ID:ratno,項目名稱:Doptor,代碼行數:11,代碼來源:SentrySeeder.php

示例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;
 }
開發者ID:rafaelvieiras,項目名稱:connect,代碼行數:19,代碼來源:TestCase.php

示例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);
 }
開發者ID:xiaohulidudu,項目名稱:laravel-blog,代碼行數:13,代碼來源:SentrySeeder.php

示例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');
     }
 }
開發者ID:kettanyam,項目名稱:20141001done,代碼行數:18,代碼來源:GroupsController.php

示例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);
 }
開發者ID:justinf111,項目名稱:laravel-blog,代碼行數:13,代碼來源:SentrySeeder.php


注:本文中的Sentry::createGroup方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。