get() ->filter(fn (Source $source) => in_array($target->type, $source->target_types, true) && $this->registry->has($source->key)); $busySourceIds = $target->findings() ->whereIn('status', ['pending', 'running']) ->pluck('source_id'); $queued = 0; foreach ($applicableSources as $source) { if ($busySourceIds->contains($source->id)) { continue; } $finding = $target->findings()->create([ 'source_id' => $source->id, 'run_by' => $runBy->id, 'status' => 'pending', ]); RunFinding::dispatch($finding->id); $queued++; } return $queued; } }