Untitled

Anonymous
plain_text
02/12/2026 9:30 AM
2.5 KB
9
Indexable
// After your ->get(), before ->each()
->get()
->map(function ($placement) use ($talent) {
    $score = 0;
    
    // Technical Skills (50 points each)
    if (!empty($talent->raw_fields['technical_skills'])) {
        $matches = array_intersect(
            $talent->raw_fields['technical_skills'],
            $placement->tags['technical_skills'] ?? []
        );
        $score += count($matches) * 50;
    }
    
    // Professions (30 points each)
    if (!empty($talent->raw_fields['professions'])) {
        $matches = array_intersect(
            $talent->raw_fields['professions'],
            $placement->tags['professions'] ?? []
        );
        $score += count($matches) * 30;
    }
    
    // Industry (20 points)
    if (in_array($talent->raw_fields['industry_background'] ?? null, $placement->tags['industries'] ?? [])) {
        $score += 20;
    }
    
    // Gender (10 points)
    if (in_array($talent->raw_fields['gender'] ?? null, $placement->tags['genders'] ?? [])) {
        $score += 10;
    }
    
    // Location (5-2 points)
    if (($placement->tags['location'] ?? null) === ($talent->raw_fields['location'] ?? null)) {
        $score += 5;
    } elseif (($placement->tags['country'] ?? null) === ($talent->raw_fields['host_country'] ?? null)) {
        $score += 3;
    } elseif ($placement->tags['is_remote'] ?? false) {
        $score += 2;
    }
    
    // Languages (15 points each)
    if (!empty($talent->raw_fields['languages'])) {
        $matches = array_intersect(
            $talent->raw_fields['languages'],
            $placement->tags['languages'] ?? []
        );
        $score += count($matches) * 15;
    }
    
    $placement->match_score = $score;
    return $placement;
})
->sortByDesc('match_score')
->take(10)
->each(function ($placement) use ($compiledPlacements, &$placements) {
    // ... rest of your code
});
Editor is loading...
Leave a Comment