{{-- 地図・周辺施設 --}}

{{-- // TODO:テストデータ--}}
@php
    $items1 = [];
    if(isset($tmp_facilities)){
        foreach($tmp_facilities as $tmp_facility){
          if(isset($tmp_facility->parent->image)){
              $item3 = new stdClass();
              $item3->img = $tmp_facility->parent->image;
              $item3->number = $tmp_facility->parent->id;
              $item3->type = $tmp_facility->parent->typeName;
              $item3->name = $tmp_facility->parent->name;
              $item3->access ="徒歩{$tmp_facility->time}分（約{$tmp_facility->distance}m）";
              $item3->lat = $tmp_facility->parent->lat;
              $item3->lng = $tmp_facility->parent->lng;
              $item3->memo = $tmp_facility->parent->memo;
              array_push($items1, $item3);
          }
        }
    }
    $items2 = $items1;
@endphp

<div class="p-detail-summary">
    <h3 class="p-detail-summary__title">{{$item->article_name}}<!--（{{$item->main_traffic_station}}
        駅）{{$item->property_name}}-->
        @if($item->price and $item->status!=4 and $item->status!=5)
        <span
            class="p-detail-summary__price"><span>{{number_format($item->price, 0, ",", ",")}}</span>万円@if($item->tax==2)<!--（税込）-->@endif</span>
        @endif
        <span class="p-detail-summary__id">No.{{$item->building_id}}</span>
          </h3>
</div>
<div class="p-detail-map-around d-flex justify-content-between">
    <ul class="p-detail-map-around__left">
        <li class="p-detail-map-around__list-head">
            <p class="p-detail-map-around__list-head-photo">写真画像</p>
            <p class="p-detail-map-around__list-head-number">施設番号<br>施設種別</p>
            <p class="p-detail-map-around__list-head-name">施設名<br>徒歩分数/距離</p>
        </li>
        @foreach($items1 as $i => $item)
            @if($i%2==0)
            <li class="p-detail-map-around__list-row border-0">
                <div class="p-detail-map-around__list-row-photo">
                    <img src="{{ $item->img }}">
                </div>
                <div class="p-detail-map-around__list-row-number">
                    <p>{{ $item->number }}</p>
                    <p>{{ $item->type }}</p>
                </div>
                <div class="p-detail-map-around__list-row-name">
                    <p>{{$item->name}}</p>
                    @if(request('action') == null)
                        @php
                            if($item->lat != ''){
                                $google = "https://maps.google.co.jp/maps/search/".$item->lat.",".$item->lng;
                            }else{
                                $google = "https://www.google.com/maps/embed/v1/place?q=".$item->pref_name.$item->city_name.$item->town_name.$item->address."&key=AIzaSyAvLqHslDD75YM0_3ZZYv_C9lYVKNLR_i0";
                            }
                        @endphp
                        <p class="clearfix">{{$item->access}} <a class="float-right" target="_blank" href="{{$google}}">Googleマップ</a></p>
                    @endif
                </div>
            </li>
            <li class="p-detail-map-around__list-row justify-content-start bg-white" style="width: 100%; word-break: break-all;">
                <p class="p-detail-map-around__list-head-photo"></p>
                <p style="width: 83%">{{$item->memo}}</p>
            </li>
            @endif
        @endforeach
    </ul>
    <ul class="p-detail-map-around__right">
        <li class="p-detail-map-around__list-head">
            <p class="p-detail-map-around__list-head-photo">写真画像</p>
            <p class="p-detail-map-around__list-head-number">施設番号<br>施設種別</p>
            <p class="p-detail-map-around__list-head-name">施設名<br>徒歩分数/距離</p>
        </li>
        @foreach($items1 as $i => $item)
            @if($i%2!=0)
            <li class="p-detail-map-around__list-row border-0">
                <div class="p-detail-map-around__list-row-photo">
                    <img style="width: 60px" src="{{ $item->img }}">
                </div>
                <div class="p-detail-map-around__list-row-number">
                    <p>{{ $item->number }}</p>
                    <p>{{ $item->type }}</p>
                </div>
                <div class="p-detail-map-around__list-row-name">
                    <p>{{$item->name}}</p>
                    <p class="clearfix">{{$item->access}} <a class="float-right" target="_blank" href="https://www.google.com/maps?q={{ $item->lat }},{{ $item->lng }}">Googleマップ</a></p>
                </div>
            </li>
            <li class="p-detail-map-around__list-row justify-content-start bg-white" style="width: 100%; word-break: break-all;">
                <p class="p-detail-map-around__list-head-photo"></p>
                <p style="width: 83%">{{$item->memo}}</p>
            </li>
            @endif
        @endforeach
    </ul>
</div>
