按照user_club_joins表的created_at字段降序排序
public function users()
{
return $this->belongsToMany(User::class, 'user_club_joins', 'club_id', 'user_id')->orderBy('user_club_joins.created_at', 'desc');
}
public function user()
{
return $this->belongsToMany(User::class, 'user_activities', 'activity_id', 'user_id')
->wherePivot('register_status', 2);
}
网友评论