---
title: "Gate integration — Connections for Laravel | Roundly"
description: "Opt in to a Gate::before hook so $user->can('publish', $team) and Laravel’s other authorization checks resolve through connections."
url: https://roundly-consulting.com/open-source/docs/connections-for-laravel/gate
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Connections for Laravel](https://roundly-consulting.com/open-source/docs/connections-for-laravel.md)

# Gate integration

Set register\_gate to true to register a Gate::before check, so a host app can authorize through connections:

```bash
CONNECTIONS_REGISTER_GATE=true
```

```php
use 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 crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## 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.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/connections-for-laravel.md)
