<style>
    .adv_box
    {
        /*
        display: grid;
        align-content: space-between;
        */
        /*
        display: flex;
        justify-content: space-between;
        */
        /*flex-direction: column;*/
    }
</style>
@foreach($keys as $key)
    @if(isset($advs[$key]) && sizeof($advs[$key]) > 0)
        <div class="widget adv_box" style="margin-top:35px;">
            <div id="car{{time()}}" class="advertisement carousel slide" data-ride="carousel" style="padding:0px">
                <div class="desktop-advert carousel-inner">
                    @foreach($advs[$key] as $idx => $adv)
                        <?php
                        $d = '';
                        $sizes = explode(" ", $key);
                        if (sizeof($sizes) > 0)
                            $d = $sizes[0];
                        else
                            $d = $key;
                        list($w, $h) = explode("x", $d);
                        ?>
                        <div class="item {{$idx == 0 ? 'active' : ''}}">
                            @if($adv->google_code != '')
                                <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
                                    <ins class="adsbygoogle"
                                        style="display:inline-block;width:{{$w}}px;height:{{$h}}px"
                                        data-ad-client="ca-pub-0209495346002620"
                                        data-ad-slot="{{$adv->google_code}}"></ins>
                                    <script>
                                    (adsbygoogle = window.adsbygoogle || []).push({});
                                </script>
                            @else
                                <a href="{{$adv->url != '' ? $adv->url : '#'}}"><img src="/files/adv/{{$adv->image}}" alt="" style="border:1px solid gray;margin:auto; "></a>
                            @endif
                        </div>
                    @endforeach
                </div>
                <div class="tablet-advert carousel-inner">
                    @foreach($advs[$key] as $idx => $adv)
                        <div class="item {{$idx == 0 ? 'active' : ''}}">
                            @if($adv->google_code != '')
                                <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
                                    <ins class="adsbygoogle"
                                        style="display:inline-block;width:{{$w}}px;height:{{$h}}px"
                                        data-ad-client="ca-pub-0209495346002620"
                                        data-ad-slot="{{$adv->google_code}}"></ins>
                                    <script>
                                    (adsbygoogle = window.adsbygoogle || []).push({});
                                </script>
                            @else
                                <a href="{{$adv->url != '' ? $adv->url : '#'}}"><img src="/files/adv/{{$adv->image}}" alt=""  style="border:1px solid gray;margin:auto;"></a>
                            @endif
                        </div>
                    @endforeach
                </div>
                <div class="mobile-advert carousel-inner">
                    @foreach($advs[$key] as $idx => $adv)
                        <div class="item {{$idx == 0 ? 'active' : ''}}">
                            @if($adv->google_code != '')
                                <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
                                    <ins class="adsbygoogle"
                                        style="display:inline-block;width:{{$w}}px;height:{{$h}}px"
                                        data-ad-client="ca-pub-0209495346002620"
                                        data-ad-slot="{{$adv->google_code}}"></ins>
                                    <script>
                                    (adsbygoogle = window.adsbygoogle || []).push({});
                                </script>
                            @else
                                <a href="{{$adv->url != '' ? $adv->url : '#'}}"><img src="/files/adv/{{$adv->image}}" alt="" style="border:1px solid gray;margin:auto;"></a>
                            @endif
                        </div>
                    @endforeach
                </div>
            </div>
        </div>
    @else
        <?php
        $d = '';
        $sizes = explode(" ", $key);
        if (sizeof($sizes) > 0)
            $d = $sizes[0];
        else
            $d = $key;
        list($w, $h) = explode("x", $d);
        ?>
        <div class="widget" style="width:{{$w}}px;height:{{$h}}px;border:1px solid gray;margin-top:35px;">

        </div>
    @endif
@endforeach
