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);
            });
        });
    }
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);
            });
        });
    }
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 ) ; } ) ; } ) ; }
Find all components which are within visible groups.

@param \Illuminate\Database\Eloquent\Builder $query
@param bool                                  $authenticated

@return \Illuminate\Database\Eloquent\Builder
Find all components which are within visible groups .