@if($boardMeta->show_list_from_view)
    @if($latest && $latest->total > 0)
    <div id="latest">
        @if($boardMeta->use_personal)
        {{-- 1:1문의 시작 --}}
        <table class="table">
            <colgroup>
                <col width="6%"/>
                @if($boardMeta->use_category)
                <col width="8%"/>
                @endif
                <col width="*"/>
                <col width="14%"/>
                <col width="14%"/>
                <col width="8%"/>
                <col width="8%"/>
            </colgroup>
            <thead>
                <tr>
                    <th>번호</th>
                    @if($boardMeta->use_category)
                    <th>분류</th>
                    @endif
                    <th>제목</th>
                    <th>작성자</th>
                    <th>작성일</th>
                    <th>조회</th>
                    <th>답변 여부</th>
                </tr>
            </thead>
            <tbody>
            @foreach($latest->list as $row)
                <tr>
                    <td>{{ $row->num }}</td>
                    @if($boardMeta->use_category)
                    <td>
                        @if($row->categoryName)
                            <label>
                                <a href="{{ $listURL }}?category={{ $row->board_category_id }}" class="me-0" rel="search">
                                    [{{ $row->categoryName }}]
                                </a>
                            </label>
                        @else
                            -
                        @endif
                    </td>
                    @endif
                    <td class="text-start">
                        @if($row->is_secret)
                            <a href="{{ $row->viewURL }}" hreflang="ko" referrerpolicy="origin" type="text/html">
                                <i class="fas fa-lock"></i> 비밀글입니다.
                            </a>
                        @elseif($row->isBlame)
                            <i class="fas fa-ban"></i> <del>{{ $row->subject }}</del>
                        @else
                            <a href="{{ $row->viewURL }}" hreflang="ko" referrerpolicy="origin" type="text/html">{{ $row->subject }}</a>
                        @endif
                        @if($row->comment_rows > 0)
                            <var>[{{ $row->comment_rows }}]</var>
                        @endif
                        @if($row->file_rows > 0)
                            <i class="fas fa-save"></i>
                        @endif
                        @if($row->link_rows > 0)
                            <i class="fas fa-external-link-alt"></i>
                        @endif
                        @if($row->image_rows > 0)
                            <i class="fas fa-image"></i>
                        @endif
                        @if($row->isNew)
                            <span class="badge bg-warning text-dark">New</span>
                        @endif
                        @if($row->isHot)
                            <span class="badge bg-danger">Hot</span>
                        @endif
                    </td>
                    <td>{{ $row->user->name }}</td>
                    <td>{{ $row->createdAt }}</td>
                    <td>{{ $row->hit }}</td>
                    <td>
                        @if($row->is_reply)
                            <span class="badge bg-success p-2">답변완료</span>
                        @else
                            <span class="badge bg-secondary p-2">접수완료</span>
                        @endif
                    </td>
                </tr>
            @endforeach
            </tbody>

            @if($latest->total > 0)
            <tfoot>
                <tr>
                    <td colspan="7">
                        {{ $latest->list->onEachSide($pageCount)->links('desktop.board.component.pagination') }}
                    </td>
                </tr>
            </tfoot>
            @endif
        </table>
        {{-- 1:1문의 종료 --}}

        @elseif($boardMeta->board_layout_type == BOARD_LAYOUT_NORMAL)

        {{-- 일반 게시글 시작 --}}
        <table class="table">
            <colgroup>
                <col width="6%"/>
                <col width="*"/>
                <col width="14%"/>
                <col width="14%"/>
                <col width="8%"/>
                <col width="8%"/>
            </colgroup>
            <thead>
                <tr>
                    <th>번호</th>
                    <th>제목</th>
                    <th>작성자</th>
                    <th>작성일</th>
                    <th>조회</th>
                    <th>추천</th>
                </tr>
            </thead>
            <tbody>
            @foreach($latest->list as $row)
                <tr>
                    <td>{{ $row->num }}</td>
                    <td class="text-start">
                        @if($boardMeta->use_category && $row->categoryName)
                            <label>
                                <a href="{{ $listURL }}?category={{ $row->board_category_id }}" rel="search">
                                    [{{ $row->categoryName }}]
                                </a>
                            </label>
                        @endif
                        @if($row->is_secret)
                            <a href="{{ $row->viewURL }}" hreflang="ko" referrerpolicy="origin" type="text/html">
                                <i class="fas fa-lock"></i> 비밀글입니다.
                            </a>
                        @elseif($row->isBlame)
                            <i class="fas fa-ban"></i> <del>{{ $row->subject }}</del>
                        @else
                            <a href="{{ $row->viewURL }}" hreflang="ko" referrerpolicy="origin" type="text/html">{{ $row->subject }}</a>
                        @endif
                        @if($row->comment_rows > 0)
                            <var>[{{ $row->comment_rows }}]</var>
                        @endif
                        @if($row->file_rows > 0)
                            <i class="fas fa-save"></i>
                        @endif
                        @if($row->link_rows > 0)
                            <i class="fas fa-external-link-alt"></i>
                        @endif
                        @if($row->image_rows > 0)
                            <i class="fas fa-image"></i>
                        @endif
                        @if($row->isNew)
                            <span class="badge bg-warning text-dark">New</span>
                        @endif
                        @if($row->isHot)
                            <span class="badge bg-danger">Hot</span>
                        @endif
                    </td>
                    <td>{{ $row->user->name }}</td>
                    <td>{{ $row->createdAt }}</td>
                    <td>{{ $row->hit }}</td>
                    <td>{{ $row->like }}</td>
                </tr>
            @endforeach
            </tbody>

            @if($latest->total > 0)
            <tfoot>
                <tr>
                    <td colspan="7">
                        {{ $latest->list->onEachSide($pageCount)->links('desktop.board.component.pagination') }}
                    </td>
                </tr>
            </tfoot>
            @endif
        </table>
        {{-- 일반 게시글 종료 --}}

        @elseif($boardMeta->board_layout_type == BOARD_LAYOUT_MEDIA)

        {{-- 사진/동영상 게시글 시작 --}}
        @if($latest->total > 0)
            <div class="row row-cols-sm-4 row-cols-xl-6 gx-3 gy-4">
            @foreach($latest->list as $row)
                <div class="col">
                    <figure class="figure h-100 d-flex flex-column">
                        <a href="{{ $row->viewURL }}" hreflang="ko" referrerpolicy="origin" type="text/html" class="ratio ratio-4x3">
                            @if($row->thumbnail)
                                <img src="{{ $row->thumbnail }}" class="figure-img img-fluid rounded object-fit-cover" alt="{{ $row->subject }}" onerror="{{ NO_IMAGE_NORMAL_SRC }}'"/>
                            @else
                                <img src="{{ NO_IMAGE_NORMAL_SRC }}" class="figure-img img-fluid rounded object-fit-cover" alt="No Image"/>
                            @endif
                        </a>
                        <figcaption class="figure-caption">
                            @if($boardMeta->use_category && $row->categoryName)
                                <label>
                                    <a href="{{ $listURL }}?category={{ $row->board_category_id }}" rel="search">
                                        [{{ $row->categoryName }}]
                                    </a>
                                </label>
                            @endif
                            @if($row->is_secret)
                                <a href="{{ $row->viewURL }}" hreflang="ko" referrerpolicy="origin" type="text/html">
                                    <i class="fas fa-lock"></i> 비밀글입니다.
                                </a>
                            @elseif($row->isBlame)
                                <i class="fas fa-ban"></i> <del>{{ $row->subject }}</del>
                            @else
                                <a href="{{ $row->viewURL }}" hreflang="ko" referrerpolicy="origin" type="text/html">{{ $row->subject }}</a>
                            @endif
                            @if($row->comment_rows > 0)
                                <var>[{{ $row->comment_rows }}]</var>
                            @endif
                            @if($row->file_rows > 0)
                                <i class="fas fa-save"></i>
                            @endif
                            @if($row->link_rows > 0)
                                <i class="fas fa-external-link-alt"></i>
                            @endif
                            @if($row->image_rows > 0)
                                <i class="fas fa-image"></i>
                            @endif
                            @if($row->isNew)
                                <span class="badge bg-warning text-dark">New</span>
                            @endif
                            @if($row->isHot)
                                <span class="badge bg-danger">Hot</span>
                            @endif
                        </figcaption>
                        <strong>{{ $row->user->name }}</strong>
                        <ul>
                            <li>{{ $row->createdAt }}</li>
                            <li>조회 <small>{{ $row->hit }}</small></li>
                            <li>좋아요 <small>{{ $row->like }}</small></li>
                        </ul>
                    </figure>
                </div>
            @endforeach
            </div>
        @else
            <div class="p-5 text-center">
                게시글이 존재하지 않습니다.
            </div>
        @endif

        <hr/>

        @if($latest->total > 0)
            {{ $latest->list->onEachSide($pageCount)->links('desktop.board.component.pagination') }}
        @endif
        {{-- 사진/동영상 게시글 종료 --}}

        @endif
    </div>
    @endif
@endif

@push('styles')
    <link rel="stylesheet" href="{{ asset('css/desktop/board/latest.css') }}"/>
@endpush
