萧十郎
请尝试我的解决方案:class User extends Authenticatable { ... public function payments() { return $this->hasMany(Payment::class, 'users_id'); }}$users = \App\User::query()->getModel();$users = $users->whereHas('payments', function ($query) { /** @var Builder $query */ $query->havingRaw('COUNT(*) = 1');})->whereNotExists(function ($query) { /** @var Builder $query */ $query->select(['receiver_id']) ->from('payments') ->whereRaw('users.id = payments.receiver_id');})->get();