$mesta2 = \DB::table('mesta')
->where('game_id', $gameId)
->join('users', 'mesta.user_id64', '=', 'users.id64')
->select(['mesta.*','users.username as username','users.avatar as avatar'])
->get();
$clear = [];
for ($i = 1; $i <= $game->mest_all; $i++) {
$find = 0;
foreach($mesta2 as $mestos) {
if($find == 0) {
if($mestos->mesto == $i) {
$find++;
$i++;
$clear[] = $mestos;
}
}
}
$clear[] = [
'mesto' => $i,
];
}
$mesta = json_encode($clear);