mini\Authorizer\AuthorizationQuery class

Documentation

Query object passed to authorization handlers

Handlers inspect the query and return:

  • true: Allow (stops processing)
  • false: Deny (stops processing)
  • null: Pass to next handler

Usage in handlers:

$auth->for(User::class)->listen(function(AuthorizationQuery $q): ?bool {
    return match ($q->ability) {
        Ability::Read => true,
        Ability::Delete => $q->instance()?->id === auth()->getUserId(),
        default => null,
    };
});

Properties (3)

public readonly mini\Authorizer\Ability|string $ability
public readonly object|string $entity
public readonly ?string $field

Methods (3)

Documentation missing

Get the entity class name

Get the entity instance, or null if class-level query

Source

src/Authorizer/AuthorizationQuery.php:24-47