Silber\Bouncer\Database\Queries\Abilities::addRoleInheritCondition PHP Method

addRoleInheritCondition() protected method

Add the role inheritence "where" clause to the given query.
protected addRoleInheritCondition ( Builder $query, Model $authority, string $roles ) : Closure
$query Illuminate\Database\Query\Builder
$authority Illuminate\Database\Eloquent\Model
$roles string
return Closure
    protected function addRoleInheritCondition(Builder $query, Model $authority, $roles)
    {
        $query->orWhere('level', '<', function ($query) use($authority, $roles) {
            $query->selectRaw('max(level)')->from($roles)->whereExists($this->getAuthorityRoleConstraint($authority));
        });
    }