hokky 1 місяць тому
батько
коміт
7b6eab17c9

+ 67 - 47
pro/app/Http/Controllers/MyPage/NoticeController.php

@@ -5,21 +5,22 @@ namespace Themes\kbgolf\pro\app\Http\Controllers\MyPage;
 use App\Http\Controllers\Controller;
 use App\Services\CallApiService;
 use Illuminate\Pagination\LengthAwarePaginator;
+use App\Services\PostService;
 
 class NoticeController extends Controller
 {
     private $callApiService;
 
-    public function __construct(CallApiService $callApiService)
+    public function __construct(CallApiService $callApiService, PostService $postService)
     {
         $this->callApiService = $callApiService;
+        $this->postService = $postService;
     }
 
     public function list()
     {
         $limit = (int)request('limit', 12);
         $page = (int)request('page', 1);
-
         $noticePage = $this->callApiService->callApi([
             'url' => 'list-type1-page',
             'data' => [
@@ -38,66 +39,85 @@ class NoticeController extends Controller
                 ]
             ]
         ]);
+        // dd($noticePage);
+
+        $noticePage['Page'] = new LengthAwarePaginator($noticePage['Page'], $noticePage['PageVars']['QueryCnt'],
+            $limit, $page, ['path' => request()->url()]);
 
         if ($this->callApiService->verifyApiError($noticePage)) {
             notify()->error($noticePage['body'], 'Error', 'bottomRight');
             return redirect()->back();
         }
 
-        $noticePage['Page'] = new LengthAwarePaginator($noticePage['Page'], $noticePage['PageVars']['QueryCnt'],
-            $limit, $page, ['path' => request()->url()]);
-
         return view('views.my-page.notice-list', compact('noticePage'));
     }
 
     public function show($id)
     {
-        $listType1Book = $this->callApiService->callApi([
-            'url' => 'list-type1-book',
-            'data' => [
-                'Book' => [
-                    [
-                        'QueryVars' => [
-                            'QueryName' => 'pro:my-page/post-details',
-                            'SimpleFilter' => "post_code='notice' and mx.id = $id",
-                            'IsntPagination' => true,
-                        ],
-                        'PageVars' => [
-                            'Limit' => 1
-                        ]
-                    ],
-                    [
-                        'QueryVars' => [
-                            'QueryName' => 'pro:my-page/post-details-prenext',
-                            'SimpleFilter' => "mx.id = (select max(id) from pro_post where id < ${id} and post_type_id = 1) and mx.status != '0'",
-                            'SubSimpleFilter' => "",
-                            'IsntPagination' => true,
-                        ],
-                        'PageVars' => [
-                            'Limit' => 1
-                        ]
-                    ],
-                    [
-                        'QueryVars' => [
-                            'QueryName' => 'pro:my-page/post-details-prenext',
-                            'SimpleFilter' => "mx.id = (select min(id) from pro_post where id > ${id} and post_type_id = 1) and mx.status != '0'",
-                            'SubSimpleFilter' => "",
-                            'IsntPagination' => true,
-                        ],
-                        'PageVars' => [
-                            'Limit' => 1
+        $limit = (int)request('limit', 10);
+        $page = (int)request('page', 1);
+        $postDetailsBook = $this->postService->getPostDetailsBook($id, $limit, $page);
+
+        if (!empty($postDetailsBook['PostDetailsPage'][0])) {
+            $userId = $postDetailsBook['PostDetailsPage'][0]['UserId'];
+            $postId = $postDetailsBook['PostDetailsPage'][0]['PostId'];
+            // dd($userId);
+            if($userId){
+                $userPick = $this->callApiService->callApi([
+                    'url' => 'users-pick',
+                    'data' => [
+                        'Page' => [ ['Id' => $userId] ]
+                    ]
+                ]);
+
+                if ($this->callApiService->verifyApiError($userPick)) {
+                    notify()->error($userPick['body'], 'Error', 'bottomRight');
+                    return redirect()->back();
+                }
+                // dd($userPick);
+                $postDetailsBook['PostDetailsPage'][0]['NickName'] = $userPick['Page'][0]['NickName'];
+            }
+            if($postId){
+                $listType1Book = $this->callApiService->callApi([
+                    'url' => 'list-type1-book',
+                    'data' => [
+                        'Book' => [
+                            [
+                                'QueryVars' => [
+                                    'QueryName' => 'pro:my-page/post-details-prenext',
+                                    'SimpleFilter' => "mx.id = (select max(id) from pro_post where id < ${postId} and post_type_id = 1) and mx.status != '0'",
+                                    'SubSimpleFilter' => "",
+                                    'IsntPagination' => true,
+                                ],
+                                'PageVars' => [
+                                    'Limit' => 1
+                                ]
+                            ],
+                            [
+                                'QueryVars' => [
+                                    'QueryName' => 'pro:my-page/post-details-prenext',
+                                    'SimpleFilter' => "mx.id = (select min(id) from pro_post where id > ${postId} and post_type_id = 1) and mx.status != '0'",
+                                    'SubSimpleFilter' => "",
+                                    'IsntPagination' => true,
+                                ],
+                                'PageVars' => [
+                                    'Limit' => 1
+                                ]
+                            ]
                         ]
-                    ],
-                ]
-            ]
-        ]);
+                    ]
+                ]);
 
-        if ($this->callApiService->verifyApiError($listType1Book)) {
-            notify()->error($listType1Book['body'], 'Error', 'bottomRight');
+                if ($this->callApiService->verifyApiError($listType1Book)) {
+                    notify()->error($listType1Book['body'], 'Error', 'bottomRight');
+                    return redirect()->back();
+                }
+            }
+        }else{
+            notify()->error($postDetailsBook['body'], 'Error', 'bottomRight');
             return redirect()->back();
         }
 
-//        dump($listType1Book);
-        return view('views.my-page.notice-details', compact('listType1Book'));
+        return view('views.my-page.notice-details', compact('postDetailsBook', 'listType1Book'));
     }
 }

+ 90 - 92
pro/resources/views/my-page/notice-details.blade.php

@@ -3,109 +3,107 @@
 @section('content')
 
 @php
-    $post = $listType1Book['Book'][0]['Page'][0];
-    $prePost = $listType1Book['Book'][1]['Page'];
-    $nextPost = $listType1Book['Book'][2]['Page'];
+    //$post = $listType1Book['Book'][0]['Page'][0];
+    $prePost = $listType1Book['Book'][0]['Page'];
+    $nextPost = $listType1Book['Book'][1]['Page'];
+    $postDetails = $postDetailsBook['PostDetailsPage'][0];
 @endphp
 
 <div class="sub notice">
-	<div class="container">
-		<div class="navi">
-			<a href="/"><i class="fa-solid fa-house"></i> 홈</a> > 커뮤니티 > 공지사항
-		</div>
-		<div class="title">
-			<h2>공지사항</h2>
-		</div>
-	</div>
-	<!--=====================================
-	BANNER PART START
-	=======================================-->
-	<!-- 필요없음 지움 
-	<section class="inner-section single-banner">
-		<div class="container">
-			<h2>공지사항</h2>
-			<ol class="breadcrumb">
-				<li class="breadcrumb-item"><a href="/">Home</a></li>
-				<li class="breadcrumb-item active" aria-current="page">
-					<a href="{{ route('notice.list') }}">공지사항</a>
-				</li>
-			</ol>
-		</div>
-	</section>
-	-->
-	<!--=====================================
-	BANNER PART END
-	=======================================-->
+   <div class="container">
+      <div class="navi">
+         <a href="/"><i class="fa-solid fa-house"></i> 홈</a> > 커뮤니티 > 공지사항
+      </div>
+      <div class="title">
+         <h2>공지사항</h2>
+      </div>
+   </div>
+   <!--=====================================
+   BANNER PART START
+   =======================================-->
+   <!-- 필요없음 지움
+   <section class="inner-section single-banner">
+      <div class="container">
+         <h2>공지사항</h2>
+         <ol class="breadcrumb">
+            <li class="breadcrumb-item"><a href="/">Home</a></li>
+            <li class="breadcrumb-item active" aria-current="page">
+               <a href="{{ route('notice.list') }}">공지사항</a>
+            </li>
+         </ol>
+      </div>
+   </section>
+   -->
+   <!--=====================================
+   BANNER PART END
+   =======================================-->
 
 
-	<!--=====================================
-		 BLOG DETAILS PART START
-	=======================================-->
-	<section class="inner-section blog-details-part blog-standard-details">
-		<div class="container">
-			<div class="row justify-content-center">
-				<div class="col-lg-12">
-					<article class="blog-details">
-						<div class="blog-details-content">
-							<div class="blog-details-top">
-								<div class="d-flex justify-content-between align-items-center">
-									<div>
-										<h2 class="blog-details-title">{{ $post['C5'] }}</h2>
-										<ul class="blog-details-meta">
-											<li>
-												<i class="fa-regular fa-calendar-days"></i>
-												<span>{{ $post['C7'] }}</span>
-											</li>
-											<li>
-												<i class="fa-solid fa-user"></i>
-												<span>{{ $post['C11'] }}</span>
-											</li>
-											<li>
-												<i class="fa-solid fa-share-nodes"></i>
-												<span>조회수 0</span>
-											</li>
-										</ul>
-									</div>
-								</div>
+   <!--=====================================
+       BLOG DETAILS PART START
+   =======================================-->
+   <section class="inner-section blog-details-part blog-standard-details">
+      <div class="container">
+         <div class="row justify-content-center">
+            <div class="col-lg-12">
+               <article class="blog-details">
+                  <div class="blog-details-content">
+                     <div class="blog-details-top">
+                        <div class="d-flex justify-content-between align-items-center">
+                           <div>
+                              <h2 class="blog-details-title">{{ $postDetails['PostTitle'] }}</h2>
+                              <ul class="blog-details-meta">
+                                 <li>
+                                    <i class="fa-regular fa-calendar-days"></i>
+                                    <span>{{ $postDetails['OfficialDate'] }}</span>
+                                 </li>
+                                 <li>
+                                    <i class="fa-solid fa-user"></i>
+                                    <span>{{ $postDetails['NickName'] }}</span>
+                                 </li>
+                                 <li>
+                                    <i class="fa-solid fa-share-nodes"></i>
+                                    <span>조회수 {{ $postDetails['ViewCnt'] }}</span>
+                                 </li>
+                              </ul>
+                           </div>
+                        </div>
 
-							</div>
+                     </div>
 
-							<!-- 내용 시작 -->
-							<div class="blog-details-cont">
-								{!! $post['C6'] !!}
-							</div>
-							<!--// 내용 끝 -->
+                     <!-- 내용 시작 -->
+                     <div class="blog-details-cont">
+                        {!! $postDetails['PostContents'] !!}
+                     </div>
+                     <!--// 내용 끝 -->
+                  </div>
+               </article>
+               <div class="blog_bottom">
+					<div class="blog-details-navigate">
+						<div class="blog-details-prev">
+							@if ($prePost)
+							    <!--<h4><a href="{{ route('notice.show', $prePost[0]['Id']) }}">{{ $prePost[0]['C2'] }}</a></h4>-->
+								<a class="nav-arrow" href="{{ route('notice.show', $prePost[0]['C3']) }}"><i class="fa-solid fa-arrow-left"></i> 이전</a>
+							@endif
 						</div>
-					</article>
-					<div class="blog_bottom">
-						<div class="blog-details-navigate">
-							<div class="blog-details-prev">
-								@if ($prePost)
-									<!--<h4><a href="{{ route('notice.show', $prePost[0]['Id']) }}">{{ $prePost[0]['C2'] }}</a></h4>-->
-									<a class="nav-arrow" href="{{ route('notice.show', $prePost[0]['Id']) }}"><i class="fa-solid fa-arrow-left"></i> 이전</a>
-								@endif
-							</div>
-							<div class="blog-details-next">
-								@if ($nextPost)
-									<!--<h4><a href="{{ route('notice.show', $nextPost[0]['Id']) }}">{{ $nextPost[0]['C2'] }}</a></h4>-->
-									<a class="nav-arrow" href="{{ route('notice.show', $nextPost[0]['Id']) }}">다음 <i class="fa-solid fa-arrow-right"></i></a>
-								@endif
-							</div>
-						</div>
-						<div class="btn_wrap">
-							<button type="button" class="btn btn_basic" onclick="location.href='{{ route('notice.list') }}'">목록</button>
+						<div class="blog-details-next">
+							@if ($nextPost)
+								<!--<h4><a href="{{ route('notice.show', $nextPost[0]['Id']) }}">{{ $nextPost[0]['C2'] }}</a></h4>-->
+								<a class="nav-arrow" href="{{ route('notice.show', $nextPost[0]['C3']) }}">다음 <i class="fa-solid fa-arrow-right"></i></a>
+							@endif
 						</div>
 					</div>
-
-
-					
+					<div class="btn_wrap">
+						<button type="button" class="btn btn_basic" onclick="location.href='{{ route('notice.list') }}'">목록</button>
+					</div>
 				</div>
-			</div>
-		</div>
-	</section>
-	<!--=====================================
-		BLOG DETAILS PART END
-	=======================================-->
+            </div>
+         </div>
+      </div>
+   </section>
+   <!--=====================================
+      BLOG DETAILS PART END
+   =======================================-->
 </div>
 
 @endsection

+ 84 - 83
pro/resources/views/my-page/notice-list.blade.php

@@ -3,90 +3,91 @@
 @section('content')
 
 <div class="sub notice">
-	<div class="container">
-		<div class="navi">
-			<a href="/"><i class="fa-solid fa-house"></i> 홈</a> > 커뮤니티 > 공지사항
-		</div>
-		<div class="title">
-			<h2>공지사항</h2>
-		</div>
-	</div>
-	<!--=====================================
-	BANNER PART START
-	=======================================-->
-	<!-- 필요없음 지움 
-	<section class="inner-section single-banner">
-		<div class="container">
-			<h2>공지사항12</h2>
-			<ol class="breadcrumb">
-				<li class="breadcrumb-item"><a href="index.html">Home</a></li>
-				<li class="breadcrumb-item active" aria-current="page">
-					<a href="{{ route('notice.list') }}">공지사항</a>
-				</li>
-			</ol>
-		</div>
-	</section>
-	-->
-	<!--=====================================
-	BANNER PART END
-	=======================================-->
+   <div class="container">
+      <div class="navi">
+         <a href="/"><i class="fa-solid fa-house"></i> 홈</a> > 커뮤니티 > 공지사항
+      </div>
+      <div class="title">
+         <h2>공지사항</h2>
+      </div>
+   </div>
+   <!--=====================================
+   BANNER PART START
+   =======================================-->
+   <!-- 필요없음 지움
+   <section class="inner-section single-banner">
+      <div class="container">
+         <h2>공지사항12</h2>
+         <ol class="breadcrumb">
+            <li class="breadcrumb-item"><a href="index.html">Home</a></li>
+            <li class="breadcrumb-item active" aria-current="page">
+               <a href="{{ route('notice.list') }}">공지사항</a>
+            </li>
+         </ol>
+      </div>
+   </section>
+   -->
+   <!--=====================================
+   BANNER PART END
+   =======================================-->
 
 
-	<!--=====================================
-	BLOG STANDARD PART START
-	=======================================-->
-	<section class="inner-section blog-standard">
-		<div class="container">
-			<div class="row justify-content-center">
-				<div class="col-lg-12">
-					<div class="row">
-						<div class="col-lg-12">
-							@component('views.partial.table-options')
-							@endcomponent
-						</div>
-						<div class="col-lg-12 list">
-							@forelse($noticePage['Page'] ?? [] as $notice)
-								<div class="blog-card">
-									<div class="blog-content">
-										<ul class="blog-meta">
-											<li>
-												<i class="fa-regular fa-calendar-days"></i>
-												<span>{{ $notice['C4'] }}</span>
-											</li>
-											<li>
-												<i class="fa-solid fa-user"></i>
-												<span>{{ $notice['C9'] }}</span>
-											</li>
-											<li>
-												<i class="fa-solid fa-share-nodes"></i>
-												<span>조회수 0</span>
-											</li>
-										</ul>
-										<h4 class="blog-title">
-											<a href="{{ route('notice.show', $notice['Id']) }}">{{ $notice['C6'] }}</a>
-										</h4>
-										<p class="blog-desc" style="display: none;">{{ $notice['C7'] }}</p>
-										<button class="blog-btn mb-2" onclick="$('.blog-desc').toggle()">
-											<span>자세히보기</span>
-											<i class="fa-solid fa-arrow-right"></i>
-										</button>
-									</div>
-								</div>
-							@empty
-							@endforelse
-						</div>
-						<div class="col-lg-12">
-							<div class="bottom-paginate d-flex">
-								{{ $noticePage['Page']->appends(['limit' => request('limit'), 'sort' => request('sort')])->links() }}
-							</div>
-						</div>
-					</div>
-				</div>
-			</div>
-		</div>
-	</section>
-	<!--=====================================
-	BLOG STANDARD PART END
-	=======================================-->
+   <!--=====================================
+   BLOG STANDARD PART START
+   =======================================-->
+   <section class="inner-section blog-standard">
+      <div class="container">
+         <div class="row justify-content-center">
+            <div class="col-lg-12">
+               <div class="row">
+                  <div class="col-lg-12">
+                     @component('views.partial.table-options')
+                     @endcomponent
+                  </div>
+                  <div class="col-lg-12 list">
+                     @forelse($noticePage['Page'] ?? [] as $notice)
+                        <div class="blog-card">
+                           <div class="blog-content">
+                              <ul class="blog-meta">
+                                 <li>
+                                    <i class="fa-regular fa-calendar-days"></i>
+                                    <span>{{ $notice['C4'] }}</span>
+                                 </li>
+                                 <li>
+                                    <i class="fa-solid fa-user"></i>
+                                    <span>{{ $notice['C9'] }}</span>
+                                 </li>
+                                 <li>
+                                    <i class="fa-solid fa-share-nodes"></i>
+                                    <span>조회수 {{ $notice['C12'] }}</span>
+                                 </li>
+                              </ul>
+                              <h4 class="blog-title">
+                                 <!-- <a href="{{ route('notice.show', $notice['Id']) }}">{{ $notice['C6'] }}</a> -->
+                                            <a href="{{ route('notice.show', $notice['C10']) }}">{{ $notice['C6'] }}</a>
+                              </h4>
+                              <p class="blog-desc" style="display: none;">{{ $notice['C7'] }}</p>
+                              <button class="blog-btn mb-2" onclick="$('.blog-desc').toggle()">
+                                 <span>자세히보기</span>
+                                 <i class="fa-solid fa-arrow-right"></i>
+                              </button>
+                           </div>
+                        </div>
+                     @empty
+                     @endforelse
+                  </div>
+                  <div class="col-lg-12">
+                     <div class="bottom-paginate d-flex">
+                        {{ $noticePage['Page']->appends(['limit' => request('limit'), 'sort' => request('sort')])->links() }}
+                     </div>
+                  </div>
+               </div>
+            </div>
+         </div>
+      </div>
+   </section>
+   <!--=====================================
+   BLOG STANDARD PART END
+   =======================================-->
 </div>
 @endsection