$clear = [];
for ($i = 1; $i <= 10; $i++) {
$clear[] = [
'mesto' => $i,
];
}
$mesta2 = \DB::table('mesta')->where('game_id', 595)->get()->keyBy('mesto');
$result = \Illuminate\Support\Collection::make($clear)->map(function ($item) use ($mesta2) {
if ($persistedItem = $mesta2->get($item['mesto'])) {
return $persistedItem;
}
return $item;
});