|
@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
5
|
5
|
use Illuminate\Http\Request;
|
6
|
6
|
use App\Models\RSVP;
|
7
|
7
|
use App\Models\GuestBook;
|
|
8
|
+use Illuminate\Support\Facades\Response;
|
8
|
9
|
|
9
|
10
|
class MainController extends Controller
|
10
|
11
|
{
|
|
@@ -66,4 +67,22 @@ class MainController extends Controller
|
66
|
67
|
|
67
|
68
|
return view('attendance', compact(['vips', 'generals']));
|
68
|
69
|
}
|
|
70
|
+
|
|
71
|
+ public function downloadVipCsv()
|
|
72
|
+ {
|
|
73
|
+ $vips = RSVP::where('is_vip', true)->get();
|
|
74
|
+
|
|
75
|
+ $csvData = "Nama,Bilangan,No Tel\n";
|
|
76
|
+ foreach ($vips as $vip) {
|
|
77
|
+ $csvData .= "{$vip->name},{$vip->member},{$vip->phone}\n";
|
|
78
|
+ }
|
|
79
|
+
|
|
80
|
+ $fileName = "vip_data.csv";
|
|
81
|
+ $headers = [
|
|
82
|
+ 'Content-Type' => 'text/csv',
|
|
83
|
+ 'Content-Disposition' => "attachment; filename=\"$fileName\"",
|
|
84
|
+ ];
|
|
85
|
+
|
|
86
|
+ return Response::make($csvData, 200, $headers);
|
|
87
|
+ }
|
69
|
88
|
}
|