瀏覽代碼

one page rsvp

am
farhan 4 月之前
父節點
當前提交
5b0c782ccd

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

@@ -8,17 +8,25 @@ use App\Models\GuestBook;
8 8
 
9 9
 class MainController extends Controller
10 10
 {
11
-    public function main() {
11
+    public function main(Request $request) {
12 12
         $rsvp = RSVP::all();
13 13
         $guestbook = GuestBook::all();
14 14
 
15
-        return view('digital-card', compact(['rsvp', 'guestbook']));
15
+        $currentUrl = $request->fullUrl();
16
+        if ($currentUrl == 'https://aliffayuna.com/') {
17
+            return view('digital-card', compact(['rsvp', 'guestbook']));
18
+        }
19
+
20
+        if ($currentUrl == 'https://rsvp.aliffayuna.com/') {
21
+            return view('rsvp-digital-card', compact(['rsvp', 'guestbook']));
22
+        }
16 23
     }
17 24
 
18 25
     public function saveRsvp(Request $request) {
19 26
         RSVP::create([
20 27
             'name' => $request->name,
21
-            'member' => $request->member
28
+            'member' => $request->member,
29
+            'phone' => $request->phone
22 30
         ]);
23 31
 
24 32
         session()->flash('success', 'Terima kasih kerana sudi menghadirkan diri!');
@@ -36,4 +44,8 @@ class MainController extends Controller
36 44
 
37 45
         return response()->json(['message' => 'Speech form submitted successfully']);
38 46
     }
47
+
48
+    public function rsvpmain() {
49
+        return view('rsvp-digital-card');
50
+    }
39 51
 }

+ 2
- 1
app/Models/RSVP.php 查看文件

@@ -13,6 +13,7 @@ class RSVP extends Model
13 13
 
14 14
     protected $fillable = [
15 15
         'name',
16
-        'member'
16
+        'member',
17
+        'phone'
17 18
     ];
18 19
 }

+ 28
- 0
database/migrations/2024_07_13_025822_add_column_phone_to_rsvp.php 查看文件

@@ -0,0 +1,28 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+use Illuminate\Support\Facades\Schema;
6
+
7
+return new class extends Migration
8
+{
9
+    /**
10
+     * Run the migrations.
11
+     */
12
+    public function up(): void
13
+    {
14
+        Schema::table('rsvps', function (Blueprint $table) {
15
+            $table->string('phone')->after('member');
16
+        });
17
+    }
18
+
19
+    /**
20
+     * Reverse the migrations.
21
+     */
22
+    public function down(): void
23
+    {
24
+        Schema::table('rsvps', function (Blueprint $table) {
25
+            $table->dropColumn('phone');
26
+        });
27
+    }
28
+};

二進制
public/assets/logosmall.png 查看文件


二進制
public/assets/logosmallest.png 查看文件


+ 106
- 0
resources/views/rsvp-digital-card.blade.php 查看文件

@@ -0,0 +1,106 @@
1
+<!DOCTYPE html>
2
+<html lang="en">
3
+<head>
4
+    <meta charset="UTF-8">
5
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+    <meta http-equiv="X-UA-Compatible" content="ie=edge">
7
+    <title>{{config('app.name')}}</title>
8
+
9
+    <link rel="preconnect" href="https://fonts.bunny.net">
10
+    <link href="https://fonts.bunny.net/css?family=figtree:400,600&display=swap" rel="stylesheet" />
11
+    <link href="https://cdn.jsdelivr.net/npm/daisyui@4.12.10/dist/full.min.css" rel="stylesheet" type="text/css" />
12
+    <meta name="csrf-token" content="{{ csrf_token() }}">
13
+
14
+    @vite(['resources/css/app.css'])
15
+</head>
16
+<body class="antialiased font-serif">
17
+    <div class="section bg-babyblue h-screen w-screen flex justify-center items-center">
18
+        <div class="flex flex-col gap-3 w-4/5 z-10">
19
+            <div class="flex justify-center">
20
+                <p class="font-normal text-base text-navbarcolor uppercase">MAJLIS PERKAHWINAN ALIFF & AYUNA</p>
21
+            </div>
22
+
23
+            <div class="flex justify-center pt-8 pb-6">
24
+                <img src="{{ asset('assets/logosmallest.png') }}" alt="Logo">
25
+            </div>
26
+
27
+            <div class="flex justify-center">
28
+                <p class="font-normal text-2xl text-navbarcolor uppercase">RSVP</p>
29
+            </div>
30
+
31
+            <div class="flex justify-center">
32
+                <form id="RSVPForm" class="flex flex-col gap-3">
33
+                    @csrf
34
+                    <label class="input input-sm input-bordered flex items-center gap-2">
35
+                        Name :
36
+                        <input type="text" name="name" class="grow"/>
37
+                    </label>
38
+            
39
+                    <label class="input input-sm input-bordered flex items-center gap-2">
40
+                        Bilangan :
41
+                        <input type="number" name="member" class="grow"/>
42
+                    </label>
43
+            
44
+                    <label class="input input-sm input-bordered flex items-center gap-2">
45
+                        No. Tel :
46
+                        <input type="number" name="phone" class="grow"/>
47
+                    </label>
48
+                    <button id="submitForm" class="bg-babybluedark rounded-lg py-2">Hantar</button>
49
+                </form>
50
+            </div>            
51
+
52
+            <div class="flex justify-center pt-2">
53
+                <a onclick="contact.showModal()" class="bg-white rounded-full py-3 px-4 text-navbarcolor">
54
+                    <i class="fa-solid fa-phone"></i>
55
+                </a>
56
+                @include('modals.contact-modal')
57
+            </div>
58
+        </div>
59
+        <img src="{{asset('assets/flower-left.png')}}" alt="" class="fixed -left-3/4 top-28">
60
+        <img src="{{asset('assets/flower-right.png')}}" alt="" class="fixed -right-3/4 top-8">
61
+    </div>
62
+
63
+    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
64
+    <script>
65
+        $(document).ready(function() {
66
+            $('#submitForm').click(function(e) {
67
+            e.preventDefault();
68
+    
69
+            var formData = $('#RSVPForm').serialize();
70
+    
71
+            $.ajax({
72
+              url: '{{ route('rsvp.save') }}',
73
+              type: 'POST',
74
+              data: formData,
75
+              success: function(response) {
76
+                if ('{{ session('success') }}') {
77
+                    showSuccessMessage('{{ session('success') }}');
78
+                }
79
+                $('#RSVPForm')[0].reset();
80
+              },
81
+              error: function(xhr, status, error) {
82
+                console.error('Error submitting form:', error);
83
+              }
84
+            });
85
+          });
86
+    
87
+          function showSuccessMessage(message) {
88
+                // Create a dynamic success message element
89
+                var successAlert = $('<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded relative" role="alert">' +
90
+                    '<span class="block sm:inline">' + message + '</span>' +
91
+                    '</div>');
92
+    
93
+                // Append the message to a suitable container in your HTML (e.g., modal, form, or body)
94
+                $('#alert-success').append(successAlert);
95
+    
96
+                // Automatically remove the message after 3 seconds
97
+                setTimeout(function() {
98
+                    successAlert.fadeOut('slow', function() {
99
+                        $(this).remove();
100
+                    });
101
+                }, 3000); // 3 seconds
102
+            }
103
+        });
104
+    </script>
105
+</body>
106
+</html>

+ 3
- 0
routes/web.php 查看文件

@@ -17,3 +17,6 @@ use App\Http\Controllers\MainController;
17 17
 Route::get('/', [MainController::class, 'main']);
18 18
 Route::post('/saveRsvp', [MainController::class, 'saveRsvp'])->name('rsvp.save');
19 19
 Route::post('/saveSpeech', [MainController::class, 'saveSpeech'])->name('speech.save');
20
+
21
+
22
+Route::get('/rsvp', [MainController::class, 'rsvpmain']);

Loading…
取消
儲存