本文整理汇总了PHP中app\Role::getAllSystemRoles方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::getAllSystemRoles方法的具体用法?PHP Role::getAllSystemRoles怎么用?PHP Role::getAllSystemRoles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Role
的用法示例。
在下文中一共展示了Role::getAllSystemRoles方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the database seeds.
*
* Create one user for every role
*
* @return void
*/
public function run()
{
$roles = \App\Role::getAllSystemRoles();
//$this->seedOnlyOwner();
foreach ($roles as $role) {
$ucfRole = ucfirst($role);
$u = factory(App\User::class, $role)->create(['name' => $ucfRole, 'email' => $role . '@' . $role . '.dev', 'password' => bcrypt($role)]);
$u->companies()->save(factory(App\Company::class, 1)->make(['name' => $ucfRole . '\'s Company']));
}
}
示例2: test_every_user_role_can_see_any_company_details
public function test_every_user_role_can_see_any_company_details()
{
// create owner with company
$owner = factory(User::class, 'owner')->create();
$owner->companies()->save($company = factory(Company::class)->create());
$roles = Role::getAllSystemRoles();
foreach ($roles as $role) {
$user = factory(User::class, $role)->create();
$this->actingAs($user)->get('/company/' . $company->id)->assertResponseStatus(200);
}
}