---
url: /filament-relation-navigator/v1.5/guide/relation-pages.md
---
# Relation pages

### Opting in

Opt in on the resource, for every relation manager, or only on the relation
managers you want:

```php
use Wit3\FilamentRelationNavigator\Concerns\InteractsWithRelationPage;

class OrdersRelationManager extends RelationManager
{
    use InteractsWithRelationPage;
}
```

| Setup                                       | Relations with a page               |
| ------------------------------------------- | ----------------------------------- |
| `HasRelationPages` on the resource          | all, minus the ones that opt out    |
| `InteractsWithRelationPage` on a manager    | only the managers that opt in       |
| A page class you wrote (see below)          | all, minus the ones that opt out    |

To leave some relations out:

```php
// On the resource
public static function hasRelationPage(string $slug): bool
{
    return $slug !== 'notes';
}

// On a relation manager, with InteractsWithRelationPage
protected static bool $hasRelationPage = false;
```

A relation manager shared by two resources opts in for both: use the
resource's `hasRelationPage()` to leave one of them out.

### URLs and slugs

| `getRelations()` entry                          | URL                         |
| ----------------------------------------------- | --------------------------- |
| `'orders' => OrdersRelationManager::class`      | `/customers/1/orders`       |
| `SupportTicketsRelationManager::class` (no key) | `/customers/1/support-tickets` |
| `RelationGroup::make('Activity', [...])`        | `/customers/1/activity`     |

The key in `getRelations()` wins; without a key, the slug is the kebab-cased
relationship name (or the group label). A relation manager can pick its own
with `protected static ?string $relationPageSlug = 'tickets';`. Slugs equal to
one of the resource's page keys (`edit`, `view`...) are skipped.

Each page is a named route, `relations.{slug}`:

```php
CustomerResource::getUrl('relations.orders', ['record' => $customer]);
```

### Authorization and behaviour

The relation manager receives the resource's **view** page as `$pageClass`
(the edit page when there is no view page), so `isReadOnly()`,
`canViewForRecord()`, `getBadge()` and every other check behave exactly as in
the tab. A relation page needs what the view page needs (its `canAccess()`
and the record's `view` policy; `update` when it stands for the edit page)
and the manager's `canViewForRecord()`; an unknown slug is a 404. The menu
only lists the pages the user can open.
