当前位置: 首页>>代码示例>>PHP>>正文


PHP Sentinel::findRoleBySlug方法代码示例

本文整理汇总了PHP中Sentinel::findRoleBySlug方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentinel::findRoleBySlug方法的具体用法?PHP Sentinel::findRoleBySlug怎么用?PHP Sentinel::findRoleBySlug使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sentinel的用法示例。


在下文中一共展示了Sentinel::findRoleBySlug方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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);
 }
开发者ID:benhanks040888,项目名称:Laravel-5-starter-kit,代码行数:16,代码来源:SentinelSeeder.php

示例2: update_my_personal_profile_with_changes

 public function update_my_personal_profile_with_changes(FunctionalTester $I)
 {
     $I->am('Admin');
     $I->wantTo('update my profile and change some informations');
     $I->expectTo('see a success confirmation message and see that my data have changed');
     /***************************************************************************************************************
      * settings
      **************************************************************************************************************/
     // we create the admin role
     $admin_role = $this->_createAdminRole();
     // we attach it to the logged user
     $admin_role->users()->attach($this->_user);
     /***************************************************************************************************************
      * run test
      **************************************************************************************************************/
     $I->amOnPage('/');
     $I->amOnRoute('users.profile');
     $I->see(trans('users.page.title.profile'), 'h2');
     $I->selectOption('gender', config('user.gender_key.male'));
     $I->fillField('last_name', 'OTHER');
     $I->fillField('first_name', 'Other');
     $I->fillField('birth_date', '01/01/1999');
     $I->fillField('phone_number', '0101010101');
     $I->fillField('email', 'other@other.fr');
     $I->fillField('address', '1 impasse Commandant Cousteau');
     $I->fillField('zip_code', 99456);
     $I->fillField('city', 'Toulon');
     $I->fillField('country', 'Maroc');
     $I->fillField('password', 'password');
     $I->fillField('password_confirmation', 'password');
     $I->click(trans('global.action.save'));
     $I->seeCurrentRouteIs('users.profile');
     $I->see(trans('global.modal.alert.title.success'), 'h3');
     $I->see(trans('users.message.account.success'));
     $this->_user->fresh();
     $I->seeRecord('users', ['last_name' => 'OTHER', 'first_name' => 'Other', 'gender' => config('user.gender_key.male'), 'birth_date' => '1999-01-01', 'status_id' => $this->_user->status_id, 'board_id' => $this->_user->board_id, 'phone_number' => '+33 1 01 01 01 01', 'email' => 'other@other.fr', 'address' => '1 impasse Commandant Cousteau', 'zip_code' => 99456, 'city' => 'Toulon', 'country' => 'Maroc']);
     $I->seeRecord('role_users', ['user_id' => $this->_user->id, 'role_id' => Sentinel::findRoleBySlug('admin')->id]);
     $I->seeRecord('activations', ['user_id' => $this->_user->id, 'completed' => true]);
     $user = Sentinel::getUserRepository()->findByCredentials(['email' => 'other@other.fr']);
     $I->assertTrue(Hash::check('test', $user->password));
 }
开发者ID:Okipa,项目名称:una.app,代码行数:41,代码来源:UserCest.php

示例3: run

 public function run()
 {
     // we remove all the files in the storage user folder
     $files = glob(storage_path('app/users/*'));
     foreach ($files as $file) {
         if (is_file($file)) {
             unlink($file);
         }
     }
     // we create the folder if it doesn't exist
     if (!is_dir($storage_path = storage_path('app/users'))) {
         if (!is_dir($path = storage_path('app'))) {
             mkdir($path);
         }
         mkdir($path . '/users');
     }
     /**
      * LEADING BOARD
      */
     $moderator_role = Sentinel::findRoleBySlug('moderator');
     // we create a user
     $user = Sentinel::register(['last_name' => 'GIRARD', 'first_name' => 'Lionel', 'email' => 'dlsba.girard@free.fr', 'status_id' => config('user.status_key.president'), 'board_id' => config('user.board_key.leading_board'), 'password' => str_random()], true);
     // we attach the user to the user role
     $moderator_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/girard.jpg'), $user->imageName('photo'), 'jpg', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     // we create a user
     $user = Sentinel::register(['last_name' => 'VARAINE', 'first_name' => 'David', 'email' => 'davidvaraine@gmail.com', 'status_id' => config('user.status_key.vice_president'), 'board_id' => config('user.board_key.leading_board'), 'password' => str_random()], true);
     // we attach the user to the user role
     $moderator_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/varaine.jpg'), $user->imageName('photo'), 'jpg', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     // we create a user
     $user = Sentinel::register(['last_name' => 'DISCAZEAU', 'first_name' => 'Gérard', 'email' => 'discazeaux.una@gmail.com', 'status_id' => config('user.status_key.treasurer'), 'board_id' => config('user.board_key.leading_board'), 'password' => str_random()], true);
     $moderator_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/users-default-avatar.png'), $user->imageName('photo'), 'png', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     // we create a user
     $user = Sentinel::register(['last_name' => 'THERIOT', 'first_name' => 'David', 'email' => 'david.theriot@free.fr', 'status_id' => config('user.status_key.secretary_general'), 'board_id' => config('user.board_key.leading_board'), 'password' => str_random()], true);
     $moderator_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/theriot.png'), $user->imageName('photo'), 'png', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     /**
      * STUDENT LEADING BOARD
      */
     // we create a user
     $user = Sentinel::register(['last_name' => 'PLANCHENAULT', 'first_name' => 'Thomas', 'email' => 't.planchenault@gmail.com', 'status_id' => config('user.status_key.student_president'), 'board_id' => config('user.board_key.student_leading_board'), 'password' => str_random()], true);
     $moderator_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/planchenault.jpg'), $user->imageName('photo'), 'jpg', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     // we create a user
     $user = Sentinel::register(['last_name' => 'DIETER', 'first_name' => 'Lara', 'email' => 'laradieter@hotmail.de', 'status_id' => config('user.status_key.student_secretary'), 'board_id' => config('user.board_key.student_leading_board'), 'password' => str_random()], true);
     $moderator_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/dieter.jpg'), $user->imageName('photo'), 'jpg', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     // we create a user
     $user = Sentinel::register(['last_name' => 'ETIENVRE', 'first_name' => 'Marianne', 'email' => 'marianne.etienvre@hotmail.fr', 'status_id' => config('user.status_key.student_treasurer'), 'board_id' => config('user.board_key.student_leading_board'), 'password' => str_random()], true);
     $moderator_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/etienvre.jpg'), $user->imageName('photo'), 'jpg', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     // we create a user
     $user = Sentinel::register(['last_name' => 'LEGOFF', 'first_name' => 'Benoit', 'email' => 'legoff.b@gmail.com', 'status_id' => config('user.status_key.student_vice_president'), 'board_id' => config('user.board_key.student_leading_board'), 'password' => str_random()], true);
     $moderator_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/legoff.jpg'), $user->imageName('photo'), 'jpg', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     /**
      * EXECUTIVE COMMITTEE
      */
     // we create a user
     $user = Sentinel::register(['last_name' => 'LORENT', 'first_name' => 'Arthur', 'email' => 'arthur.lorent@gmail.com', 'status_id' => config('user.status_key.communication_commission'), 'board_id' => config('user.board_key.executive_committee'), 'password' => 'password'], true);
     // we attach the user to the admin role
     $admin = \Sentinel::findRoleBySlug('admin');
     $admin->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/lorent.jpg'), $user->imageName('photo'), 'jpg', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     // we create a user
     $user = Sentinel::register(['last_name' => 'PROTT', 'first_name' => 'Thierry', 'email' => 'thprott@free.fr', 'status_id' => config('user.status_key.sportive_commission'), 'board_id' => config('user.board_key.executive_committee'), 'password' => str_random()], true);
     $moderator_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/prott.jpg'), $user->imageName('photo'), 'jpg', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
//.........这里部分代码省略.........
开发者ID:Okipa,项目名称:una.app,代码行数:101,代码来源:UsersTableSeeder.php


注:本文中的Sentinel::findRoleBySlug方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。