public function inGroup($group, $recursive = false)
{
$memberOf = $this->getGroups([], $recursive);
$groups = is_array($group) ? $group : [$group];
foreach ($groups as $group) {
// We need to iterate through each given group that the
// model must be apart of, then go through the models
// actual groups and perform validation.
$exists = $memberOf->filter(function (Group $parent) use($group) {
return $this->validateGroup($group, $parent);
})->count() !== 0;
if (!$exists) {
// If the current group isn't at all contained
// in the memberOf collection, we'll
// return false here.
return false;
}
}
return true;
}