瀏覽代碼

show latest first

master
farhan 4 月之前
父節點
當前提交
06ee5a5b06
共有 2 個檔案被更改,包括 29 行新增13 行删除
  1. 1
    1
      app/Http/Controllers/MainController.php
  2. 28
    12
      resources/views/modals/show-all-guestbook.blade.php

+ 1
- 1
app/Http/Controllers/MainController.php 查看文件

@@ -12,7 +12,7 @@ class MainController extends Controller
12 12
         $rsvp = RSVP::all();
13 13
         $guestbooks = GuestBook::orderBy('created_at', 'desc')->take(5)->get();
14 14
         $totalPages = $guestbooks->count();
15
-        $allguestbooks = GuestBook::all();
15
+        $allguestbooks = GuestBook::orderBy('created_at', 'desc')->get();
16 16
 
17 17
         $host = $request->getHost();
18 18
 

+ 28
- 12
resources/views/modals/show-all-guestbook.blade.php 查看文件

@@ -1,15 +1,31 @@
1 1
 <dialog id="allguestbook" class="modal">
2 2
     <div class="modal-box w-11/12 max-w-5xl">
3
-      <h3 class="text-lg font-bold">Semua Ucapan</h3>
4
-      @foreach ($allguestbooks as $allguestbook)
5
-          <p>{{$allguestbook->name}}</p>
6
-          <p>{{$allguestbook->speech}}</p>
7
-          <hr class="border-t-1 border-gray-300 my-5 w-4/5 self-center ">
8
-      @endforeach
9
-      <div class="modal-action">
10
-        <form method="dialog">
11
-            <button class="btn">Tutup</button>
12
-        </form>
13
-      </div>
3
+        <h3 class="text-lg font-bold pb-2">Semua Ucapan</h3>
4
+        <div id="scrollableContent" class="max-h-96 overflow-auto">
5
+            @foreach ($allguestbooks as $allguestbook)
6
+                <p class="font-semibold">{{$allguestbook->name}}</p>
7
+                <p>{{$allguestbook->speech}}</p>
8
+                <hr class="border-t-1 border-gray-300 my-5 w-full self-center">
9
+            @endforeach
10
+        </div>
11
+        <div class="modal-action">
12
+            <form method="dialog">
13
+                <button class="btn">Tutup</button>
14
+            </form>
15
+        </div>
14 16
     </div>
15
-</dialog>
17
+</dialog>
18
+
19
+@push('script')
20
+<script>
21
+    document.addEventListener('DOMContentLoaded', function () {
22
+        var dialog = document.getElementById('allguestbook');
23
+        if (dialog) {
24
+            dialog.addEventListener('show', function () {
25
+                var scrollableContent = document.getElementById('scrollableContent');
26
+                scrollableContent.scrollTop = scrollableContent.scrollHeight;
27
+            });
28
+        }
29
+    });
30
+</script>
31
+@endpush

Loading…
取消
儲存