System status now ignores hidden groups for guests - Fixes #2577

This commit is contained in:
James Brooks
2017-06-19 14:23:32 +01:00
parent 19ac600082
commit af3d5ab493
3 changed files with 36 additions and 6 deletions

View File

@@ -192,6 +192,23 @@ class Component extends Model implements HasPresenter
return $query->where('enabled', '=', true);
}
/**
* Find all components which are within visible groups.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param bool $authenticated
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeAuthenticated(Builder $query, $authenticated)
{
return $query->when(!$authenticated, function (Builder $query) {
return $query->whereDoesntHave('group', function (Builder $query) {
$query->where('visible', ComponentGroup::VISIBLE_AUTHENTICATED);
});
});
}
/**
* Finds all components which are disabled.
*