我们来说说几种查询分组的方法
$groups = Sentry::findAllGroups();
try
{
$group = Sentry::findGroupById(1);
}
catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e)
{
echo '分组不存在';
}
try
{
$group = Sentry::findGroupByName('admin');
}
catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e)
{
echo '分组不存在';
}
try
{
$group = Sentry::findGroupById(1);
// 获取用户的权限
$groupPermissions = $group->getPermissions();
}
catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e)
{
echo '分组不存在';
}