ht3aa/link-to-relation-text-column

A text column that provide a link to the view or edit page of column relation (the relation should have a filament resource with view or edit page)

Fund package maintenance!
ht3aa

Installs: 9

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/ht3aa/link-to-relation-text-column

v3.0.4 2025-12-30 10:34 UTC

README

Latest Version on Packagist Total Downloads

LinkToRelationTextColumn Example

Installation

You can install the package via composer (for now only support filament v3):

composer require ht3aa/link-to-relation-text-column

Usage

The LinkToRelationTextColumn class extends Filament's TextColumn and automatically creates clickable links to the view or edit page of related models in your Filament tables.

Basic Usage

Import the class in your Filament resource:

use Ht3aa\LinkToRelationTextColumn\LinkToRelationTextColumn;

Then use it in your table definition. The column will automatically detect the related model and find its corresponding Filament resource:

use Ht3aa\LinkToRelationTextColumn\LinkToRelationTextColumn;

public static function table(Table $table): Table
{
    return $table
        ->columns([
            LinkToRelationTextColumn::make('user.name')
                ->label('User'),
            // ... other columns
        ]);
}

The column will:

  • Automatically detect the related model (e.g., User from the user relation)
  • Find the corresponding Filament resource for that model
  • Create a link to the view page (if available) or edit page (if view is not available)
  • Display an icon (arrow-top-right-on-square) when a link is available

Specifying a Resource Manually

If you need to explicitly specify which Filament resource to use, you can use the relationResource() method:

use Ht3aa\LinkToRelationTextColumn\LinkToRelationTextColumn;
use App\Filament\Resources\UserResource;

public static function table(Table $table): Table
{
    return $table
        ->columns([
            LinkToRelationTextColumn::make('user.name')
                ->label('User')
                ->relationResource(UserResource::class),
            // ... other columns
        ]);
}

Example: Complete Table Definition

use Filament\Tables\Table;
use Ht3aa\LinkToRelationTextColumn\LinkToRelationTextColumn;

public static function table(Table $table): Table
{
    return $table
        ->columns([
            TextColumn::make('id'),
            LinkToRelationTextColumn::make('author.name')
                ->label('Author')
                ->searchable(),
            LinkToRelationTextColumn::make('category.name')
                ->label('Category')
                ->relationResource(CategoryResource::class),
            // ... other columns
        ]);
}

Credits

License

The MIT License (MIT). Please see License File for more information.