Is sortable() and/or searchable() possible on a HasOneThrough relation?

I don't think I have asked this before... But it is a hard one. The setup: - One Staff can have many positions. - One Position has one Discipline. - Positions have an end_date field The question: Is it possible to have a HasOneThrough relation work with sortable() on the StaffResource? Relation:
public function latestDiscipline(): HasOneThrough
{ {
return $this->hasOneThrough(Discipline::class, Position::class, 'staff_id', 'id', 'id', 'discipline_id')
->where('is_active', true)
->orderBy('end_date', 'desc');
}
}

public function getLatestDisciplineNameAttribute()
{
$latestDiscipline = $this->latestDiscipline()->first();
return $latestDiscipline ? $latestDiscipline->name : null;
}
public function latestDiscipline(): HasOneThrough
{ {
return $this->hasOneThrough(Discipline::class, Position::class, 'staff_id', 'id', 'id', 'discipline_id')
->where('is_active', true)
->orderBy('end_date', 'desc');
}
}

public function getLatestDisciplineNameAttribute()
{
$latestDiscipline = $this->latestDiscipline()->first();
return $latestDiscipline ? $latestDiscipline->name : null;
}
Text column:
TextColumn::make('latest_discipline_name')
->label('Discipline')
// ->searchable()
->sortable()
->toggleable(),
TextColumn::make('latest_discipline_name')
->label('Discipline')
// ->searchable()
->sortable()
->toggleable(),
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server