<tr>
    <th>
        <div>
            <p>アットホーム入稿用画像<br />（周辺環境写真）</p>
            <strong><span class="@if(count($portal_athome_facility)>8) alart @endif">{{ count($portal_athome_facility) }}/8枚</span></strong>
            @if($athome_facility_status == 1)
                <a href="javascript:facilityUploadPortal({{ $article_id }}, 'all', '', 'athome')" class="kt-bt kt-bg-4 mt-5">施設画像をセット（すべて）</a>
            @else
                <button type="button" class="modal-facility-portal kt-bt kt-bg-4 mt-4" data-n="2" autocomplete="off">施設画像をセット（すべて）</button>
            @endif
            <button type="button" class="modal-portal-detail kt-bt kt-bg-5 mt-2" data-n="5" autocomplete="off">施設画像をセット（一部）</button>
        </div>
    </th>
    <td>
        <div id="sortable_article_image" class="p-regist__sorttable portal_image_trash_group">
            @include('admin.objects.components.hidden', ['name' => 'athome_del_facility_id', 'value' => '', 'class' => 'delete_portal_image_input'])
            <div id="image_list_portal" class="row portal_facility_sorttable">
                @php $stt = 0; @endphp
                @foreach($portal_athome_facility as $photo)
                    @php $stt++; @endphp
                    <div class="col-2 mt10 mb10 sorttable_item @if($stt>8)line-red @endif">
                        <span class="bg-non-dark position-relative title_number mb10">画像{{ $stt }}</span>
                        <label class="p-portalupload w-100 file_multiple_label" data-id="{{ $stt }}" for="fileMutilInputAthomeFacility{{ $stt }}">
                            <img class="p-img-size" src="{{ $photo->storageLink.'?v='.strtotime(now()) }}">
                            <canvas width="0" height="0"></canvas>
                            <p class="p-imgupload__text">クリックまたは<br>ドラッグ&amp;ドロップ</p>
                            <input id="fileMutilInputAthomeFacility{{ $stt }}" type="file" accept="image/png, image/gif, image/jpeg" name="athome_facility_file_input[{{ $stt }}]" class="file_multiple_input d-none">
                            <input type="hidden" name="athome_facility_file_path{{ $stt }}" value="{{ $photo->file_path }}">
                        </label>
                        <div class="w-100 position-relative mt10">
                            <label class="require-portal float-left">必須</label>
                            @include('admin.objects.components.selectbox', ['class'  =>  'w100', 'name' => 'athome_facility_property_sub'.$stt, 'placeholder' => '物件への距離', 'options' => $photo_facility_athome, 'selected' => selectedFacilityAthome($photo->type_upload, $photo->facility_property)])
                        </div>
                        <div class="w-100 position-relative mt10">
                            <label class="require-portal float-left">必須</label>
                            @include('admin.objects.components.input', ['class'  =>  'w100 position-relative', 'name' => 'athome_facility_name'.$stt, 'placeholder' => '施設名称', 'value' => $photo->facility_name])
                        </div>
                        <div class="w-100 position-relative mt10">
                            <label class="require-portal float-left">必須</label>
                            @include('admin.objects.components.input', ['class'  =>  'w80 position-relative', 'name' => 'athome_facility_distance'.$stt, 'placeholder' => '物件への距離', 'value' => $photo->distance])
                            <label>m</label>
                        </div>
                        <div class="w-100 position-relative mt10">
                            @include('admin.objects.components.input', ['name' => 'athome_facility_created_at'.$stt, 'class' => 'cal_picker_maxdate w-100', 'placeholder' => '撮影日', 'value'=>\Carbon\Carbon::parse($photo->created_at)->format('Y/m/d')] )
                        </div>
                        @include('admin.objects.components.textarea_house', ['name' => 'athome_facility_memo'.$stt, 'class' => 'img_text mt10 position-relative', 'count' => 50, 'site' => 1, 'placeholder' => '画像コメント', 'value' => $photo->facility_memo])
                        <div class="mt10 w-100">
                            @include('admin.objects.components.hidden', ['name' => 'athome_facility_id'.$stt, 'value' => $photo->id])
                            @include('admin.objects.components.hidden', ['name' => 'athome_facility_order'.$stt, 'value' => '', 'class' => 'portal_order'])
                            @include('admin.objects.components.hidden', ['name' => 'athome_type_upload'.$stt, 'value' => $photo->type_upload])
                            @include('admin.objects.components.btn', ['name' => 'athome_del_facility_portal', 'class' => 'btn_imagedel w-100 position-relative delete_portal_image_btn', 'title' => '削除', 'type' => 'button', 'dataPhoto' => $photo->id])
                        </div>
                    </div>
                @endforeach
                @if($stt < 8)
                    @for($j = $stt+1; $j <= 8;$j++)
                        <div class="col-2 mt10 mb10 sorttable_item">
                            <span class="bg-non-dark title_number mb10">画像{{ $j }}</span>
                            <label class="p-portalupload w-100 file_multiple_label" data-id="{{ $j }}" for="fileMutilInputAthomeFacility{{ $j }}">
                                <canvas width="0" height="0"></canvas>
                                <p class="p-imgupload__text">クリックまたは<br>ドラッグ&amp;ドロップ</p>
                                <input id="fileMutilInputAthomeFacility{{ $j }}" type="file" accept="image/png, image/gif, image/jpeg" name="athome_facility_file_input[{{ $j }}]" class="file_multiple_input d-none">
                                <input type="hidden" name="athome_facility_file_path{{ $j }}" value="">
                            </label>
                            <div class="w-100 position-relative mt10">
                                <label class="require-portal float-left">必須</label>
                                @include('admin.objects.components.selectbox', ['class'  =>  'w100', 'name' => 'athome_facility_property_sub'.$j, 'placeholder' => '物件への距離', 'options' => $photo_facility_athome, 'selected' => ''])
                            </div>
                            <div class="w-100 position-relative mt10">
                                <label class="require-portal float-left">必須</label>
                                @include('admin.objects.components.input', ['class'  =>  'w100 position-relative', 'name' => 'athome_facility_name'.$j, 'placeholder' => '施設名称', 'value' => ''])
                            </div>
                            <div class="w-100 position-relative mt10">
                                <label class="require-portal float-left">必須</label>
                                @include('admin.objects.components.input', ['class'  =>  'w80 position-relative', 'name' => 'athome_facility_distance'.$j, 'placeholder' => '物件への距離', 'value' => ''])
                                <label>m</label>
                            </div>
                            <div class="w-100 position-relative mt10">
                                @include('admin.objects.components.input', ['name' => 'athome_facility_created_at'.$j, 'class' => 'cal_picker_maxdate w-100', 'placeholder' => '撮影日', 'value'=> ''] )
                            </div>
                            @include('admin.objects.components.textarea_house', ['name' => 'athome_facility_memo'.$j, 'class' => 'img_text mt10 position-relative', 'count' => 50, 'site' => 1, 'placeholder' => '画像コメント', 'value' => ''])
                            <div class="mt10 w-100 position-relative">
                                @include('admin.objects.components.hidden', ['name' => 'athome_facility_id'.$j, 'value' => ''])
                                @include('admin.objects.components.hidden', ['name' => 'athome_facility_order'.$j, 'value' => '', 'class' => 'portal_order'])
                                @include('admin.objects.components.hidden', ['name' => 'athome_type_upload'.$j, 'value' => ''])
                                @include('admin.objects.components.btn', ['name' => 'athome_del_facility_portal', 'class' => 'btn_imagedel w-100', 'title' => '削除', 'type' => 'button'])
                            </div>
                        </div>
                    @endfor
                @endif
            </div>
        </div>
        @if(count($portal_athome_facility_del) > 0)
            <div class="button_bar pt-close">
                <a class="p-search-common__collapse-link p-search-common__collapse-link--open" data-toggle="collapse" href="#athome_facility_del" role="button" aria-expanded="true" aria-controls="homes_image_del">前回のデータ</a>
            </div>
            <div id="athome_facility_del" class="p-regist__sorttable portal_image_delete_group collapse">
                <div id="image_list_portal" class="row portal_facility_sorttable">
                    @php
                        $num_portal_facility_athome = count($portal_athome_facility_del) > 8 ? count($portal_athome_facility_del) : 8;
                        $stt = $num_portal_facility_athome;
                    @endphp
                    @foreach($portal_athome_facility_del as $photo)
                        @php $stt++; @endphp
                        <div class="col-2 mt10 mb10 restore-item sorttable_item">
                            <span class="position-relative title_number mb10 bg-non-dark">優先画像.{{ $stt - $num_portal_facility_athome }}</span>
                            <label class="p-portalupload w-100 file_multiple_label" data-id="{{ $stt }}" for="fileMutilInputAthomeFacility{{ $stt }}">
                                <img class="p-img-size" src="{{ $photo->storageLink }}">
                                <canvas width="0" height="0"></canvas>
                                <p class="p-imgupload__text">クリックまたは<br>ドラッグ&amp;ドロップ</p>
                                <input id="fileMutilInputAthomeFacility{{ $stt }}" type="file" accept="image/png, image/gif, image/jpeg" name="athome_facility_file_input[{{ $stt }}]" class="file_multiple_input d-none">
                                <input type="hidden" name="athome_facility_file_path{{ $stt }}" value="{{ $photo->file_path }}">
                            </label>
                            <div class="w-100 position-relative mt10">
                                <label class="require-portal float-left">必須</label>
                                @include('admin.objects.components.selectbox', ['class'  =>  'w100', 'name' => 'athome_facility_property_sub'.$stt, 'placeholder' => '物件への距離', 'options' => $photo_facility_athome, 'selected' => selectedFacilityAthome($photo->type_upload, $photo->facility_property)])
                            </div>
                            <div class="w-100 position-relative mt10">
                                <label class="require-portal float-left">必須</label>
                                @include('admin.objects.components.input', ['class'  =>  'w100 position-relative', 'name' => 'athome_facility_name'.$stt, 'placeholder' => '施設名称', 'value' => $photo->facility_name])
                            </div>
                            <div class="w-100 position-relative mt10">
                                <label class="require-portal float-left">必須</label>
                                @include('admin.objects.components.input', ['class'  =>  'w80 position-relative', 'name' => 'athome_facility_distance'.$stt, 'placeholder' => '物件への距離', 'value' => $photo->distance])
                                <label>m</label>
                            </div>
                            <div class="w-100 position-relative mt10">
                                @include('admin.objects.components.input', ['name' => 'athome_facility_created_at'.$stt, 'class' => 'cal_picker_maxdate w-100', 'placeholder' => '撮影日', 'value'=>\Carbon\Carbon::parse($photo->created_at)->format('Y/m/d')] )
                            </div>
                            @include('admin.objects.components.textarea_house', ['name' => 'athome_facility_memo'.$stt, 'class' => 'img_text mt10 position-relative', 'count' => 50, 'site' => 1, 'placeholder' => '画像コメント', 'value' => $photo->facility_memo])
                            <div class="mt10 w-100">
                                @include('admin.objects.components.hidden', ['name' => 'athome_facility_id'.$stt, 'value' => $photo->id, 'class' => 'portal_photo_id'])
                                @include('admin.objects.components.hidden', ['name' => 'athome_facility_order'.$stt, 'value' => '', 'class' => 'portal_order'])
                                @include('admin.objects.components.hidden', ['name' => 'athome_type_upload'.$stt, 'value' => $photo->type_upload])
                                @include('admin.objects.components.btn', ['name' => '', 'class' => 'btn_imagedel w-100 position-relative delete_portal_facility_image_btn', 'title' => '削除', 'type' => 'button', 'dataPhoto' => $photo->id])
                            </div>
                        </div>
                    @endforeach
                    <div class="col-4 mt10 mb10 item-center">
                        <a href="javascript:void(0)" class="restore_portal_image_facility_btn saved_del" data-photo="{{ implode(',', $portal_athome_facility_del->pluck('id')->toArray()) }}">この内容で上枠内を上書きする</a>
                    </div>
                </div>
            </div>
        @endif
    </td>
</tr>
