FilamentF
Filament3y ago
Adam

Table Relationship 'name' not 'id'

Apologies if this has been asked before but I can seem to find the solution in the docs or in Discord.

Currently, when viewing records using the table builder, I can see a column's relationship's
id
but I want it to display the relationship's
name
column.

The model's relationship:
public function resort() {
        return $this->belongsTo(Resort::class, 'id', 'resort');
    }


Here is what I've tried:
TextColumn::make('resort.resort'),


this results in
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'resorts.resort' in 'where clause'


I've also tried:
TextColumn::make('resorts.resort'),


and the table column is blank

this just outputs the
id

TextColumn::make('resort'),
Was this page helpful?