F
Filamentβ€’13mo ago
Quin.

Column relationship

hello i wanted to show the domainextension price! but i think i got something wrong 😦
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('domain')->searchable(),
Tables\Columns\BadgeColumn::make('domain_status')
->colors([
'success' => static fn ($status): bool => strpos(strtolower($status), 'vrij') !== false,
'danger' => static fn ($status): bool => strpos(strtolower($status), 'bezet') !== false,
]),
Tables\Columns\TextColumn::make('domainextension.price'),
])
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('domain')->searchable(),
Tables\Columns\BadgeColumn::make('domain_status')
->colors([
'success' => static fn ($status): bool => strpos(strtolower($status), 'vrij') !== false,
'danger' => static fn ($status): bool => strpos(strtolower($status), 'bezet') !== false,
]),
Tables\Columns\TextColumn::make('domainextension.price'),
])
domainExtension Model:
public function domaincheckrecord()
{
return $this->hasMany(DomainCheckRecord::class);
}
public function domaincheckrecord()
{
return $this->hasMany(DomainCheckRecord::class);
}
DomainCheckRecord model:
public function domainextension():belongsTo
{
return $this->belongsTo(DomainExtension::class);
}
public function domainextension():belongsTo
{
return $this->belongsTo(DomainExtension::class);
}
Solution:
Fixed it! just needed to add the foreignkey in the domainextension():belongsTo
Jump to solution
3 Replies
ChesterS
ChesterSβ€’13mo ago
Is your example correct? You called both your relation methods domaincheckrecord but then you are using domainextension.price in your column It should probably be domaincheckrecord.price unless you copied the wrong relation
Quin.
Quin.OPβ€’13mo ago
your right it is the wrong in my message but the code it was right] he needs the price from domainextension
Solution
Quin.
Quin.β€’13mo ago
Fixed it! just needed to add the foreignkey in the domainextension():belongsTo
Want results from more Discord servers?
Add your server