PHPackages                             abather/relation-components - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. abather/relation-components

ActiveLibrary[Database &amp; ORM](/categories/database)

abather/relation-components
===========================

column and entry for relations

v0.3(2mo ago)480↓75%MITPHPPHP ^8.2

Since Mar 29Pushed 2mo agoCompare

[ Source](https://github.com/Abather/relation-components)[ Packagist](https://packagist.org/packages/abather/relation-components)[ Docs](https://github.com/abather/relation-components)[ RSS](/packages/abather-relation-components/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (3)Dependencies (4)Versions (4)Used By (0)

Relation Components
===================

[](#relation-components)

[![Relation Components](https://camo.githubusercontent.com/3ab453a7618f095bf730fdb740583cbb26df45cc805ebf32a0a3bdb29dd8c7f2/68747470733a2f2f692e6962622e636f2f64536a333278792f72656c6174696f6e2d636f6d706f6e656e74732d62616e6e65722e6a7067)](https://camo.githubusercontent.com/3ab453a7618f095bf730fdb740583cbb26df45cc805ebf32a0a3bdb29dd8c7f2/68747470733a2f2f692e6962622e636f2f64536a333278792f72656c6174696f6e2d636f6d706f6e656e74732d62616e6e65722e6a7067)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6ec6e9ff6d415c2d0a09cfc689b99eb01ab5c9beb4c745afde707a3a7472d191/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616261746865722f72656c6174696f6e2d636f6d706f6e656e74732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/abather/relation-components)[![Total Downloads](https://camo.githubusercontent.com/84426968bee2495e329c55d30c1c4ee312fb17c15281dafcf84e111a1d9e88a5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616261746865722f72656c6174696f6e2d636f6d706f6e656e74732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/abather/relation-components)

Filament table columns and infolist entries for `belongsTo` and `morphTo` relationships.

Requirements
------------

[](#requirements)

- [Filament](https://filamentphp.com) v4+

Installation
------------

[](#installation)

```
composer require abather/relation-components
```

---

Usage
-----

[](#usage)

### `BelongsToColumn` / `BelongsToEntry`

[](#belongstocolumn--belongstoentry)

Pass the resource class directly to `make()`. All configuration is derived automatically.

```
use Abather\RelationComponents\Tables\Columns\BelongsToColumn;
use Abather\RelationComponents\Infolists\Components\BelongsToEntry;

BelongsToColumn::make(UserResource::class)

BelongsToEntry::make(UserResource::class)
```

Available options (all chainable):

```
BelongsToColumn::make(UserResource::class)
    ->page('edit')          // default: 'view'
    ->withIcon(false)       // default: true
    ->label('Owner')
    ->color('success')
```

---

### `MorphToColumn` / `MorphToEntry`

[](#morphtocolumn--morphtoentry)

Pass the relation name to `make()` and provide the type map via `->types()`.

```
use Abather\RelationComponents\Tables\Columns\MorphToColumn;
use Abather\RelationComponents\Infolists\Components\MorphToEntry;

MorphToColumn::make('subject')
    ->types([
        Farm::class => FarmResource::class,
        Plot::class => PlotResource::class,
    ])

MorphToEntry::make('subject')
    ->types([
        Farm::class => FarmResource::class,
        Plot::class => PlotResource::class,
    ])
```

> **N+1 warning:** eager-load the relation to avoid per-row queries.
>
> ```
> // In your resource:
> public static function getEloquentQuery(): Builder
> {
>     return parent::getEloquentQuery()->with('subject');
> }
> ```

---

### `BelongsToSelect`

[](#belongstoselect)

A form select for `belongsTo` relationships. Pass the resource class to `make()` — the relation, label, and title attribute are all derived automatically.

```
use Abather\RelationComponents\Forms\Components\BelongsToSelect;

BelongsToSelect::make(UserResource::class)
```

Available options (all chainable):

```
BelongsToSelect::make(UserResource::class)
    ->withIcon(false)       // default: true — shows resource icon as suffix
    ->preload(false)        // default: true
    ->label('Assigned To')
```

---

Global Configuration
--------------------

[](#global-configuration)

Since these classes extend Filament's `TextColumn` and `TextEntry`, they can be configured globally in your `AppServiceProvider` the same way:

```
use Abather\RelationComponents\Forms\Components\BelongsToSelect;
use Abather\RelationComponents\Tables\Columns\BelongsToColumn;
use Abather\RelationComponents\Tables\Columns\MorphToColumn;
use Abather\RelationComponents\Infolists\Components\BelongsToEntry;
use Abather\RelationComponents\Infolists\Components\MorphToEntry;

public function boot(): void
{
    BelongsToSelect::configureUsing(fn (BelongsToSelect $select) => $select
        ->preload(false)
        ->withIcon(false)
    );

    BelongsToColumn::configureUsing(fn (BelongsToColumn $column) => $column
        ->color('primary')
        ->openUrlInNewTab(false)
    );

    MorphToEntry::configureUsing(fn (MorphToEntry $entry) => $entry
        ->color('warning')
    );
}
```

---

Customization
-------------

[](#customization)

Any method from `TextColumn` / `TextEntry` can be chained to override the defaults:

```
BelongsToColumn::make(UserResource::class)
    ->color('success')
    ->icon('heroicon-o-user')
    ->openUrlInNewTab(false)

MorphToEntry::make('subject')
    ->types([Farm::class => FarmResource::class])
    ->color('warning')
    ->icon(null)
```

---

Authorization Visibility
------------------------

[](#authorization-visibility)

By default, columns and entries are always rendered regardless of whether the current user is authorized to view the related record's page. You can change this by calling `->hideWhenNotAuthorizedToView()`, which will completely hide the field if the user does not have permission to view the related resource.

```
BelongsToColumn::make(UserResource::class)
    ->hideWhenNotAuthorizedToView()

BelongsToEntry::make(UserResource::class)
    ->hideWhenNotAuthorizedToView()

MorphToEntry::make('subject')
    ->types([Farm::class => FarmResource::class])
    ->hideWhenNotAuthorizedToView()
```

When this is enabled, the visibility is determined as follows:

- If no related record is loaded yet (e.g. on a list page), `canViewAny()` on the resource is checked.
- If a related record is available, `canView($record)` on the resource is checked.

The field is hidden entirely when the check fails — the user will not see the field at all, not just an empty value.

> **URL authorization:** Even without `->hideWhenNotAuthorizedToView()`, the link is always authorization-aware. The URL is only generated when all of the following are true: a related record exists, the target page exists on the resource, and `canView($record)` passes. If the user is not authorized to view the record, the field renders as plain text with no link.

---

Visibility on Parent Pages
--------------------------

[](#visibility-on-parent-pages)

By default, columns and entries are automatically hidden when shown inside the related resource's own relation manager pages. For example, a `UserResource` column will be hidden on any of User's relation manager pages.

To override this behavior, chain `->hiddenOn([])`:

```
BelongsToColumn::make(UserResource::class)
    ->hiddenOn([])
```

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance83

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

3

Last Release

85d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2d032b178010eeffd089ecd6f75934079dc36d2d41328827f1d19c729572cbeb?d=identicon)[Abather](/maintainers/Abather)

---

Top Contributors

[![Abather](https://avatars.githubusercontent.com/u/18185658?v=4)](https://github.com/Abather "Abather (7 commits)")

---

Tags

laravelrelationfilamentmorphTobelongsTotextColumnTextEntry

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/abather-relation-components/health.svg)

```
[![Health](https://phpackages.com/badges/abather-relation-components/health.svg)](https://phpackages.com/packages/abather-relation-components)
```

###  Alternatives

[relaticle/custom-fields

User Defined Custom Fields for Laravel Filament

16445.8k](/packages/relaticle-custom-fields)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3913.7k](/packages/rawilk-profile-filament-plugin)[tomatophp/filament-locations

Database Seeds for Countries / Cities / Areas / Languages / Currancy with ready to use resources for FilamentPHP

2322.2k6](/packages/tomatophp-filament-locations)[okeonline/filament-archivable

A filament plugin to use archivable models

208.4k](/packages/okeonline-filament-archivable)[martinpetricko/filament-restore-or-create

FilamentPHP package that adds ability to check for similar deleted records and restore them instead of creating new ones.

113.0k](/packages/martinpetricko-filament-restore-or-create)[wsmallnews/filament-nestedset

Filament nestedset tree builder powered by kalnoy/nestedset with Filament v4 and v5 support

206.5k14](/packages/wsmallnews-filament-nestedset)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
