It sounds like you need a scope where you can sort by the joined model
public function scopeHometeam($query, $column='name', $direction = 'desc') {
return $query->whereHas('Hometeam', function ($query) use ($column, $direction) {
return $query->orderBy($column, $direction);
}
}
$matches = Match::Hometeam()->get();
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community