Просмотр исходного кода

메인 photo section을 전 게시판 미디어(이미지/YouTube 썸네일)로 확장

- Board::getLatestMedia / BoardService::latestMedia 추가 (비밀글·1:1글 제외)
- 메인 PC 3행 6열(18개), 모바일 기존 개수 유지
- 캡션 분류/게시판 라벨은 주석 처리

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
KIM-JINO5 2 дней назад
Родитель
Сommit
dfb021d7ec

+ 2 - 2
app/Http/Controllers/MainController.php

@@ -46,8 +46,8 @@ class MainController extends Controller
         // 공지사항
         $notice = $this->boardService->latest('notice', 1, DEFAULT_LIST_PER_PAGE);
 
-        // 사진게시판
-        $photo = $this->boardService->latest('photo', 1, DEFAULT_LIST_PER_PAGE);
+        // 전체 게시판 미디어(사진/동영상) - PC 3행 6열(18개)
+        $photo = $this->boardService->latestMedia(1, (DEVICE_TYPE_1 ? 18 : DEFAULT_LIST_PER_PAGE));
 
         // 최신 뉴스
         $news = $this->_news();

+ 54 - 0
app/Models/Board.php

@@ -605,6 +605,60 @@ class Board extends Model
         ];
     }
 
+    /**
+     * 전체 게시판 최근 미디어(썸네일 보유) 게시글 조회
+     */
+    public function getLatestMedia(int $page, int $perPage): object
+    {
+        $sql = "
+            SELECT
+                COUNT(*) AS total
+            FROM
+                tb_post PST
+                JOIN tb_board BRD ON BRD.id = PST.board_id
+            WHERE
+                PST.thumbnail IS NOT NULL AND PST.thumbnail != ''
+                AND PST.is_notice = 0 AND PST.is_speaker = 0
+                AND PST.is_secret = 0 AND PST.is_personal = 0
+                AND BRD.is_display = 1 AND PST.is_delete = 0;
+        ";
+
+        $total = DB::selectOne($sql)->total;
+
+        $sql = "
+            SELECT
+                BRD.code, BRD.name AS boardName,
+                BCA.name AS categoryName,
+                PST.id, PST.board_id, PST.board_category_id, PST.user_id, PST.thumbnail, PST.subject, PST.content,
+                PST.sid, PST.username, PST.email, PST.comment_rows, PST.is_reply, PST.is_personal, PST.is_secret,
+                PST.is_notice, PST.is_speaker, PST.is_html, PST.use_comment, PST.receive_email, PST.hit, PST.like, PST.dislike,
+                PST.blame, PST.ip_address, PST.user_agent, PST.device_type, PST.file_rows, PST.image_rows,
+                PST.link_rows, PST.tag_rows, PST.is_delete, PST.created_at
+            FROM
+                tb_post PST
+                INNER JOIN tb_board BRD ON BRD.id = PST.board_id
+                LEFT JOIN tb_board_category BCA ON BCA.id = PST.board_category_id
+                LEFT JOIN users USR ON USR.id = PST.user_id
+            WHERE
+                PST.thumbnail IS NOT NULL AND PST.thumbnail != ''
+                AND PST.is_notice = 0 AND PST.is_speaker = 0
+                AND PST.is_secret = 0 AND PST.is_personal = 0
+                AND BRD.is_display = 1 AND PST.is_delete = 0
+            ORDER BY
+                PST.created_at DESC, PST.id DESC
+            LIMIT ?, ?;
+        ";
+
+        $list = $this->getPaginator(
+            DB::select($sql, [$this->getPageOffset($page), $perPage]), $total, $perPage, $page, null
+        );
+
+        return (object)[
+            'total' => $total,
+            'list' => $list
+        ];
+    }
+
     /**
      * 게시판 최근 게시글 조회
      */

+ 21 - 0
app/Services/BoardService.php

@@ -174,6 +174,27 @@ class BoardService
         return $latest;
     }
 
+    /**
+     * 전체 게시판 최근 미디어 게시글
+     */
+    public function latestMedia(int $page = 1, int $perPage = DEFAULT_LIST_PER_PAGE)
+    {
+        $cacheName = sprintf('latest-media-%d-%d', $page, $perPage);
+        if (!$latest = Cache::get($cacheName)) {
+            $latest = $this->boardModel->getLatestMedia($page, $perPage);
+            if($latest->total) {
+                $num = listNum($latest->total, $page, $perPage);
+                foreach ($latest->list as $i => $row) {
+                    $row->num = $num--;
+                    $latest->list[$i] = $this->_filter($row);
+                }
+                $latest->list->filter();
+            }
+            Cache::tags('latest-board')->put($cacheName, $latest, CACHE_EXPIRE_TIME);
+        }
+        return $latest;
+    }
+
     /**
      * 게시판 설정 값 조회
      */

+ 11 - 3
resources/views/desktop/main.blade.php

@@ -136,15 +136,15 @@
     <section class="photo">
         <div class="row align-items-end">
             <div class="col">
-                일상/풍경/사진
+                포토/미디어
             </div>
             <div class="col text-end">
-                <a href="{{ route('board.list', 'photo') }}">전체보기</a>
+                <a href="{{ route('recently') }}">전체보기</a>
             </div>
         </div>
         <hr/>
         @if($photo && $photo->total > 0)
-            <div class="row row-cols-sm-4 row-cols-xl-6">
+            <div class="row row-cols-6">
             @foreach($photo->list as $row)
                 <div class="col">
                     <figure class="figure h-100 d-flex flex-column">
@@ -154,13 +154,21 @@
                             </a>
                         @endif
                         <figcaption class="figure-caption">
+                            {{--
                             @if($row->categoryName)
                                 <label>
                                     <a href="{{ $row->listURL }}?category={{ $row->board_category_id }}" rel="search">
                                         [{{ $row->categoryName }}]
                                     </a>
                                 </label>
+                            @else
+                                <label>
+                                    <a href="{{ $row->listURL }}" rel="search">
+                                        [{{ $row->boardName }}]
+                                    </a>
+                                </label>
                             @endif
+                            --}}
                             @if($row->is_secret)
                                 <a href="{{ $row->viewURL }}" hreflang="ko" referrerpolicy="origin" type="text/html" target="_self">
                                     <i class="fas fa-lock"></i> 비밀글입니다.

+ 10 - 2
resources/views/mobile/main.blade.php

@@ -136,10 +136,10 @@
     <section class="photo">
         <div class="row align-items-end">
             <div class="col">
-                일상/풍경/사진
+                포토/미디어
             </div>
             <div class="col text-end">
-                <a href="{{ route('board.list', 'photo') }}">전체보기</a>
+                <a href="{{ route('recently') }}">전체보기</a>
             </div>
         </div>
         <hr/>
@@ -153,13 +153,21 @@
                         </a>
                     @endif
                     <figcaption class="figure-caption">
+                        {{--
                         @if($row->categoryName)
                             <label>
                                 <a href="{{ $row->listURL }}?category={{ $row->board_category_id }}" rel="search">
                                     [{{ $row->categoryName }}]
                                 </a>
                             </label>
+                        @else
+                            <label>
+                                <a href="{{ $row->listURL }}" rel="search">
+                                    [{{ $row->boardName }}]
+                                </a>
+                            </label>
                         @endif
+                        --}}
                         @if($row->is_secret)
                             <a href="{{ $row->viewURL }}" hreflang="ko" referrerpolicy="origin" type="text/html" target="_self">
                                 <i class="fas fa-lock"></i> 비밀글입니다.