All packages
Connections for Laravel
Gate integration
Set register_gate to true to register a Gate::before check, so a host app can authorize through connections:
CONNECTIONS_REGISTER_GATE=trueuse Illuminate\Support\Facades\Gate;
$user->can('publish', $team); // true when $user has 'publish' on $team
Gate::forUser($user)->allows('publish', $team); // the same check
Gate::authorize('publish', $team); // throws AuthorizationException when nothing grants it- The ability name is the permission string; the check runs hasPermissionThroughConnection(), so wildcards, the cache and enforce_active_on_check all apply.
- The hook answers only when the user and the first argument are both Eloquent models implementing Connectable.
- It returns true when the connection grants the ability and null otherwise — it never denies, so your policies and Gate definitions still decide every other case.
- Blade’s @can and the can: route middleware go through the same Gate.
- It is off by default so installing the package never surprises a host’s own authorization.
Show your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.