Policy<T extends Object> class abstract

Groups authorization logic for one model type (Laravel Policy).

Methods default to deny; override the ones you need and add custom abilities through extra.

Constructors

Policy()
Policies are usually const.
const

Properties

extra → Map<String, GateCallback>
Non-standard abilities keyed by name.
no setter
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

before(Authenticatable? user, String ability) → FutureOr<Object?>
Runs before every ability; return true/false/AuthResponse to short-circuit or null to continue.
create(Authenticatable? user) → FutureOr<Object?>
Whether user may create models.
delete(Authenticatable? user, T model) → FutureOr<Object?>
Whether user may delete model.
dispatch(Authenticatable? user, String ability, List<Object?> args) → FutureOr<Object?>
Dispatches ability to the matching method. args starts with the model (or is empty for viewAny/create).
forceDelete(Authenticatable? user, T model) → FutureOr<Object?>
Whether user may delete model for good.
handles(String ability) → bool
Whether the policy handles ability.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
restore(Authenticatable? user, T model) → FutureOr<Object?>
Whether user may restore the soft deleted model.
toString() → String
A string representation of this object.
inherited
update(Authenticatable? user, T model) → FutureOr<Object?>
Whether user may update model.
view(Authenticatable? user, T model) → FutureOr<Object?>
Whether user may view model.
viewAny(Authenticatable? user) → FutureOr<Object?>
Whether user may list models (viewAny).

Operators

operator ==(Object other) → bool
The equality operator.
inherited