Pārlūkot izejas kodu

general and button

master
farhan 3 mēnešus atpakaļ
vecāks
revīzija
c52c0e1a5a

+ 19
- 1
app/Http/Controllers/MainController.php Parādīt failu

@@ -74,7 +74,7 @@ class MainController extends Controller
74 74
 
75 75
         $csvData = "\xEF\xBB\xBF" . "Nama,Bilangan,No Tel\n";
76 76
         foreach ($vips as $vip) {
77
-            $csvData .= "{$vip->name},{$vip->member},\t{$vip->phone}\n";
77
+            $csvData .= "\t{$vip->name},{$vip->member},\t{$vip->phone}\n";
78 78
         }
79 79
 
80 80
         $fileName = "vip_data.csv";
@@ -85,4 +85,22 @@ class MainController extends Controller
85 85
 
86 86
         return Response::make($csvData, 200, $headers);
87 87
     }
88
+
89
+    public function downloadGeneralCsv()
90
+    {
91
+        $generals = RSVP::where('is_vip', false)->get();
92
+
93
+        $csvData = "\xEF\xBB\xBF" . "Nama,Bilangan,No Tel\n";
94
+        foreach ($generals as $general) {
95
+            $csvData .= "\t{$general->name},{$general->member},\t{$general->phone}\n";
96
+        }
97
+
98
+        $fileName = "general_data.csv";
99
+        $headers = [
100
+            'Content-Type' => 'text/csv',
101
+            'Content-Disposition' => "attachment; filename=\"$fileName\"",
102
+        ];
103
+
104
+        return Response::make($csvData, 200, $headers);
105
+    }
88 106
 }

+ 2
- 1
resources/views/attendance.blade.php Parādīt failu

@@ -30,7 +30,7 @@
30 30
                 @endforeach
31 31
                 </tbody>
32 32
             </table>
33
-            <a href="{{ route('download.vip.csv') }}" class="btn">Download VIP Data</a>
33
+            <a href="{{ route('download.vip.csv') }}" class="rounded-full border-solid border-2 border-navbarcolor py-1 px-3 font-medium text-gray-600">Download VIP Data</a>
34 34
         </div>
35 35
         
36 36
         <div>
@@ -53,6 +53,7 @@
53 53
                 @endforeach
54 54
                 </tbody>
55 55
             </table>
56
+            <a href="{{ route('download.general.csv') }}" class="rounded-full border-solid border-2 border-navbarcolor py-1 px-3 font-medium text-gray-600">Download General Data</a>
56 57
         </div>
57 58
     </div>
58 59
 </body>

+ 2
- 1
routes/web.php Parādīt failu

@@ -20,4 +20,5 @@ Route::post('/saveSpeech', [MainController::class, 'saveSpeech'])->name('speech.
20 20
 Route::get('/guestbook', [MainController::class, 'fetchGuestbook'])->name('guestbook.ajax');
21 21
 
22 22
 Route::get('/admin/attendance', [MainController::class, 'attendance']);
23
-Route::get('/download-vip-csv', [MainController::class, 'downloadVipCsv'])->name('download.vip.csv');
23
+Route::get('/download-vip-csv', [MainController::class, 'downloadVipCsv'])->name('download.vip.csv');
24
+Route::get('/download-vip-csv', [MainController::class, 'downloadGeneralCsv'])->name('download.general.csv');

Notiek ielāde…
Atcelt
Saglabāt